RogueWave hash set ordering

D

Dervish

Here is pseudocode:

typedef int CarID;
typedef RWTPtrHashSet<CarID,HashAdaptorCarID, CarIDEqualTo>
container_type;
typedef RWTPtrHashSetIterator<CarID,HashAdaptorCarID, CarIDEqualTo>
iterator_type;

//Implementations of HashAdaptorCarID and CarIDEqualTo are obvious.

container_type container;
container.insert(new CarID (1));
container.insert(new CarID (3));
container.insert(new CarID (4));
container.insert(new CarID (6));
container.insert(new CarID (7));

iterator_type it (container);

CarID * id = NULL;
while ((id = iterator_()))
{
cout << "DEBUG: " << *id << endl;
}

Result is:
1
3
4
6
7

For what reason (since hash container is not ordered) results are
ordered? Can I rely on this fact? Or it can be broken under some
conditions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top