VR-Link API Documentation for HLA 1.3
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
DtHashlist Class Reference

DtHashlist is deprecated and provided for backwards compatibility only. More...

+ Collaboration diagram for DtHashlist:

List of all members.

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.
DtHashlistoperator= (const DtHashlist &orig)
 Assignment operator - Does not replace the DtHashlist's list.
virtual DtListItemadd (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 DtListlist () 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 DtListkeys () 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 DtListItemitemLookup (const DtBaseHashKey &key) const
 Look up something in the list, return DtListItem.
virtual DtListbucketFromHashKey (const DtBaseHashKey &key) const
 Determine the bucket from the hash key.
virtual DtListItembucketItemLookup (const DtBaseHashKey &key) const
 Look up an item in a bucket.

Protected Attributes

int myNumBuckets
const bool myListIsMine
DtListmyList
 Regular DtList containing all of the items added to the hash list, without regard to key information.
DtListmyBuckets
 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.

Detailed Description

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.

Deprecated:
This class is deprecated, please use std::map

Constructor & Destructor Documentation

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 DtHashlist::~DtHashlist ( ) [virtual]

Destructor.

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.


Member Function Documentation

virtual DtListItem* DtHashlist::add ( const DtBaseHashKey key,
void *  data,
void **  oldData = NULL 
) [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.

virtual DtList& DtHashlist::bucketFromHashKey ( const DtBaseHashKey key) const [protected, virtual]

Determine the bucket from the hash key.

virtual DtListItem* DtHashlist::bucketItemLookup ( const DtBaseHashKey key) const [protected, virtual]

Look up an item in a bucket.

virtual void DtHashlist::empty ( ) [virtual]

Remove all keys and data from the list.

virtual DtListItem* DtHashlist::itemLookup ( const DtBaseHashKey key) const [protected, virtual]

Look up something in the list, return DtListItem.

virtual const DtList* DtHashlist::keys ( ) const [virtual]

Returns a DtList of DtHashKey*'s representing the set of keys with which data is currently associated.

virtual const DtList* DtHashlist::list ( ) const [virtual]

Returns a DtList of void*'s which are the data that you have added to the hash list (independent of hash keys).

virtual void* DtHashlist::lookup ( const DtBaseHashKey key) const [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.

void * DtHashlist::operator[] ( const DtBaseHashKey key) const [inline, virtual]

Provide a [] index into a DtHashList.

virtual void DtHashlist::print ( ) const [virtual]

Prints the data in the hash list.

virtual void* DtHashlist::remove ( const DtBaseHashKey key) [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 void DtHashlist::setFromOther ( const DtHashlist orig) [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.


Member Data Documentation

Array of buckets (DtLists of DtHashItems).

DtList of keys (DtBaseHashKeys).

DtList* DtHashlist::myList [protected]

Regular DtList containing all of the items added to the hash list, without regard to key information.

const bool DtHashlist::myListIsMine [protected]
int DtHashlist::myNumBuckets [protected]
const int DtHashlist::theDfltNumBuckets [static, protected]

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


The documentation for this class was generated from the following file:

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)