![]() |
VR-Link API Documentation for HLA 1.3
|
DtHashlist is deprecated and provided for backwards compatibility only. More...
Collaboration diagram for DtHashlist:Public Member Functions | |
| DtHashlist (int numBuckets=theDfltNumBuckets) | |
| Default constructor. | |
| DtHashlist (DtList *list, int numBuckets=theDfltNumBuckets) | |
| Constructor for a DtHashlist that uses an external DtList constructed by the user. | |
| virtual | ~DtHashlist () |
| Destructor. | |
| DtHashlist (const DtHashlist &orig) | |
| Copy constructor - always uses an internal list, so if you want your copy to use an external list, do not use the copy constructor. | |
| DtHashlist & | operator= (const DtHashlist &orig) |
| Assignment operator - Does not replace the DtHashlist's list. | |
| virtual DtListItem * | add (const DtBaseHashKey &key, void *data, void **oldData=NULL) |
| Add something to the list. | |
| virtual void * | remove (const DtBaseHashKey &key) |
| Remove something from the list. | |
| virtual void * | lookup (const DtBaseHashKey &key) const |
| Lookup something in the list, return data pointer. | |
| virtual void * | operator[] (const DtBaseHashKey &key) const |
| Provide a [] index into a DtHashList. | |
| virtual const DtList * | list () const |
| Returns a DtList of void*'s which are the data that you have added to the hash list (independent of hash keys). | |
| virtual void | print () const |
| Prints the data in the hash list. | |
| virtual const DtList * | keys () const |
| Returns a DtList of DtHashKey*'s representing the set of keys with which data is currently associated. | |
| virtual void | empty () |
| Remove all keys and data from the list. | |
| virtual void | setFromOther (const DtHashlist &orig) |
| Sets the contents of this hash list to match those of other. | |
Protected Member Functions | |
| virtual DtListItem * | itemLookup (const DtBaseHashKey &key) const |
| Look up something in the list, return DtListItem. | |
| virtual DtList & | bucketFromHashKey (const DtBaseHashKey &key) const |
| Determine the bucket from the hash key. | |
| virtual DtListItem * | bucketItemLookup (const DtBaseHashKey &key) const |
| Look up an item in a bucket. | |
Protected Attributes | |
| int | myNumBuckets |
| const bool | myListIsMine |
| DtList * | myList |
| Regular DtList containing all of the items added to the hash list, without regard to key information. | |
| DtList * | myBuckets |
| Array of buckets (DtLists of DtHashItems). | |
| DtList | myKeys |
| DtList of keys (DtBaseHashKeys). | |
Static Protected Attributes | |
| static const int | theDfltNumBuckets |
| Pick a reasonable large number as the default. | |
DtHashlist is deprecated and provided for backwards compatibility only.
std::map<T> always provides better performance than this implementation of a hash list.
A DtHashlist is used to store associations between keys and arbitrary pieces of data passed as void*. Keys must be instances of a class derived from DtBaseHashKey (defined in vlHashKeys.h). A subclass of DtHashKey defines a hashing function that hashes to an unsigned long, as well as a stringRep function that converts your key to a string representation. This allows DtHashlist to compare two DtHashKeys without knowing what type of DtHashKey subclass they actually are. You can add, remove and look up data by its DtHashKey.
| DtHashlist::DtHashlist | ( | int | numBuckets = theDfltNumBuckets | ) |
Default constructor.
Creates and uses a regular DtList to store the list of data items that you add.
| DtHashlist::DtHashlist | ( | DtList * | list, |
| int | numBuckets = theDfltNumBuckets |
||
| ) |
Constructor for a DtHashlist that uses an external DtList constructed by the user.
|
virtual |
Destructor.
| DtHashlist::DtHashlist | ( | const DtHashlist & | orig | ) |
Copy constructor - always uses an internal list, so if you want your copy to use an external list, do not use the copy constructor.
Instead, use the standard with-external-list constructor to create an empty hash list, then use setFromOther or the assignment operator to copy the contents.
|
virtual |
Add something to the list.
The actual pointer is stored, so you should make sure the pointer remains valid until after you remove the data from the hash list. At any given time, only one data item may be associated with a particular key. If add is called with a key with which an item is already associated, the old item is replaced with the new, and the old item is returned in the optional oldData argument for deletion by the user. Otherwise, oldData will be set to NULL.
|
protectedvirtual |
Determine the bucket from the hash key.
|
protectedvirtual |
Look up an item in a bucket.
|
virtual |
Remove all keys and data from the list.
|
protectedvirtual |
Look up something in the list, return DtListItem.
|
virtual |
Returns a DtList of DtHashKey*'s representing the set of keys with which data is currently associated.
|
virtual |
Returns a DtList of void*'s which are the data that you have added to the hash list (independent of hash keys).
|
virtual |
Lookup something in the list, return data pointer.
| DtHashlist& DtHashlist::operator= | ( | const DtHashlist & | orig | ) |
Assignment operator - Does not replace the DtHashlist's list.
Just empties the DtHashlist, and then sets its contents to those of the original using setFromOther.
|
inlinevirtual |
Provide a [] index into a DtHashList.
|
virtual |
Prints the data in the hash list.
|
virtual |
Remove something from the list.
Returns the data that was associated with the key, so that you can cast it to the right type and delete it.
|
virtual |
Sets the contents of this hash list to match those of other.
Data pointers that have been added to orig are copied, but the items that they point to are not.
|
protected |
Array of buckets (DtLists of DtHashItems).
|
protected |
Regular DtList containing all of the items added to the hash list, without regard to key information.
|
protected |
|
protected |
|
staticprotected |
Pick a reasonable large number as the default.
Make it a prime number to increase the chances of a good hashing distribution. We need to define it here to get around a bug with g++