473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Very large array?

I am using a "unsigned long long" as a label to identify various
transactions that are taking place in my program.

The label is reserved during the lifetime of the transaction and then
released for re-use. There may be many transactions taking place at any
time. I need to mark those labels which are in-use so that a new label
assignment does not choose one which is currently in-use.

If the number of possible labels was small (say 100) then I could
simply use an array of booleans (boolean labels[100]) and set the
corresponding element to true to denote in-use.

But the label is a 64 bit value ranging from 0 to 0xffffffff. What's
the best way of representing the in-use state of all label values
without having to waste memory on a vast array? (Perhaps just using
memory for those values which are in-use.)

I suspect that one of the STL classes might be the way to go, but I'm
not sure which to choose.

There are two possibilities. Either I just want a yes/no answer as to
whether a label exists (i.e. whether it is in-use), or I might also
want to store a string for only those labels which are in-use.

Any ideas what is the best solution for these two possibilites?

Mar 16 '06 #1
4 2413
Apologies. Please ignore the root message in this thread.

I intended to post to the C++ group, but selected C by mistake.

Mar 16 '06 #2
cb****@my-deja.com wrote:
I am using a "unsigned long long" as a label to identify various
transactions that are taking place in my program.

The label is reserved during the lifetime of the transaction and then
released for re-use. There may be many transactions taking place at any
time. I need to mark those labels which are in-use so that a new label
assignment does not choose one which is currently in-use.


Why?

There are at least 2^64 distinct `unsigned long long'
values (that's 18,446,744,073,709,551,616 distict values,
for those keeping score at home). If you consume them at
a rate of one GHz -- one billion transactions per second --
it will take more than five hundred eighty-four years to
exhaust the supply. Even then, you'll only be in trouble
if some transactions are still running after all that time.
(Studies of human/computer interaction suggest that most
users find response times greater than half a millennium
to be annoying.)

The bug reports will not begin to arrive until sometime
after the year 2590. If you're still around to address them,
be sure to check with your uncle Methuselah before hurrying
to issue a patch.

--
Eric Sosman
es*****@acm-dot-org.invalid
Mar 16 '06 #3
Eric Sosman wrote:
cb****@my-deja.com wrote:
I am using a "unsigned long long" as a label to identify various
transactions that are taking place in my program.

I looked up long in the book "The C Programming Language", second
edition by Kernighan and Richtie. How come on page 36 they say:

"In addition; there are a number of qualifiers that can be applied to
these basic data types. short and long apply to integers".

But on page 211, section A8.2, they put both long and short as a
type-specifier, not a type-qualifier.

The sentence on page 36 seems to imply that long is being used as a
type-qualifer and not a type-specifier. When using long in conjunction
with long or int, does makes it a type-qualifier, but not a
type-specifier?

Chad

Mar 16 '06 #4


Chad wrote On 03/16/06 09:37,:
Eric Sosman wrote:
cb****@my-deja.com wrote:

I am using a "unsigned long long" as a label to identify various
transactions that are taking place in my program.


I looked up long in the book "The C Programming Language", second
edition by Kernighan and Richtie. How come on page 36 they say:

"In addition; there are a number of qualifiers that can be applied to
these basic data types. short and long apply to integers".

But on page 211, section A8.2, they put both long and short as a
type-specifier, not a type-qualifier.

The sentence on page 36 seems to imply that long is being used as a
type-qualifer and not a type-specifier. When using long in conjunction
with long or int, does makes it a type-qualifier, but not a
type-specifier?


K&R's book ("K&R II") describes the C language of the
original 1989 ANSI Standard ("C89," or "C90" for the date
of its adoption by ISO), and in that version of the language
there is no `long long'. In 1999 a new version of the
Standard ("C99") was adopted by ISO and ANSI, and this version
adds the `long long' type (and some others) to the C89
repertoire. This type has at least sixty-four bits, hence
about 1.9e19 distinct values.

Also, some pre-1999 compilers accept `long long' as an
extension to the C89 language. Most, it seems, use it to
designate a 64-bit integer.

K&R have not yet produced a third edition of their book
to match the C99 Standard, and it is widely believed (with or
without justification) that they probably don't intend to.

--
Er*********@sun.com

Mar 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Developwebsites | last post by:
const int MAX=999; class person { protected: char firstname, lastname; int ID; public: person();
3
by: Alex Vinokur | last post by:
Dann Corbit has implemented function int ilog2 (unsigned long) at http://groups.google.com/groups?selm=lkPa4.2165%24I41.1498%40client Is exist a similar C++-function for very large numbers,...
2
by: xain | last post by:
HtmlString includes a web page, and soon it is converted to Html file. In the web page, they are images, and some of them are large. They are so large, in fact they are going to destroy my Tables,...
0
by: Marc van Boven | last post by:
I'm stuck with the following problem: My nusoap-client calls a server-function giveCombination(). The function giveCombination should return something like array( => array( 'a_id' => 6,...
10
by: cbdeja | last post by:
I am using a "unsigned long long" as a label to identify various transactions that are taking place in my program. The label is reserved during the lifetime of the transaction and then released...
38
by: djhulme | last post by:
Hi, I'm using GCC. Please could you tell me, what is the maximum number of array elements that I can create in C, i.e. char* anArray = (char*) calloc( ??MAX?? , sizeof(char) ) ; I've...
58
by: mailursubbu | last post by:
Hi How to write a program to get the factorial of 4096. I am working on a Linux m/c. Best Regards, Subra
10
by: Peter Duniho | last post by:
This is kind of a question about C# and kind of one about the framework. Hopefully, there's an answer in there somewhere. :) I'm curious about the status of 32-bit vs 64-bit in C# and the...
11
by: Icemokka | last post by:
Hi, I'm need to upload a big file ( 600Mb+ ) to a BLOB field in MSSQL 2005. My code looks like this : fs = New FileStream(sFilePath, FileMode.Open) Dim ByteArray(fs.Length) As Byte...
1
by: parvtb | last post by:
I know STL vector works. But in case STL is not available, what can one do to allocate large memory size in c++ through operator "new"? For instance, I am writing a sort algorithm, and here's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.