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?
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?