>Vectors should do the trick. Of course it depends on how you want to look
>things up. If you want to index on strings, I would check out hashmaps.

Brian,

 thanks! I want to keep a simple indexed array, I want to use it to keep
the block map of XBlockFile. I'm planning to have a vector of vectors, one
vector for each type which contains the block map entries. This will make
for a tiny speedup in block look-up, especially as wasted blocks will be
treated as an own block type. This way only entries for wasted blocks will
be searched when looking for storage for a block. Is Vector OK for this, or
is there something especially aimed at tree-like structures in the standard
library?

>For vectors you'll want something like:
>
>vector<Ptr> myVector(10);
>myVector[2] = somePtr;
>
>Which would give you a ten-element "array". Vectors are actually very close
>to arrays, where as "valarray" is more like a vector. Alas...

 What's a vector here? I only know vectors from maths, where they are used
to describe a line in 3D space etc... ?

>For hashmaps, you specify an index type, a comparison function, and a data
>type to store. Then you use them like arrays:
>
>hashmap<char*, int> someMap;
>someMap["someString"] = someNumber;

 Hmmm... A hash is probably faster than a vector, especially for lots of
items, is it? I need the fastest method here. currently with 20 000 blocks
it takes 3 ticks to add a new block, which is too much.

>Do you have a good C++ reference? If not, I can give you the nitty gritty
>about these classes when you know which you want to use.

 The only C++ class ref I have pretty much expects you know the classes
already. It's more of a syntax lookup in case you forgot the order of
params etc., so a quick update on how I can use that would be cool.
Especially I need: adding/deleting items (=resizing the array), and what
limits the classes have (i.e. It should use unsigned longs for indices or
we'll have a severe limit on stack size).

Cheers,
-- M. Uli Kusterer

------------------------------------------------------------
             http://www.weblayout.com/witness
       'The Witnesses of TeachText are everywhere...'

--- HELP SAVE HYPERCARD: ---
Details at: http://www.hyperactivesw.com/SaveHC.html
Sign: http://www.giguere.uqam.ca/petition/hcpetition.html

Reply via email to