VR-Link API Documentation for DIS
vlHashlist.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  ** Copyright (c) 1992-2010 VT MAK
00003  ** All rights reserved.
00004  *********************************************************************/
00008 #pragma once
00009 
00010 #include "vlList.h"
00011 #include "vlHashKeys.h"
00012 
00013 #ifdef DtUSE_UTILITIES_NAMESPACE
00014 namespace DtUSE_UTILITIES_NAMESPACE
00015 {
00016 #endif
00017 
00018 
00019 
00023    class DT_DLL_VLUTIL DtHashItem
00024    {
00025    public:
00026 
00028       DtHashItem(const DtBaseHashKey& key, DtListItem* item);
00029 
00031       virtual ~DtHashItem();
00032 
00034       DtHashItem(const DtHashItem& orig);
00035 
00037       DtHashItem& operator=(const DtHashItem& orig);
00038 
00040       virtual const DtBaseHashKey& hashKey() const;
00041 
00043       virtual DtListItem* listItem() const;
00044       virtual DtListItem* keyItem() const;
00045       virtual void setKeyItem(DtListItem* keyItem);
00046 
00047    protected:
00048 
00049       DtBaseHashKey* myKey;
00050       DtListItem* myItem;
00051       DtListItem* myKeyItem;
00052    };
00053 
00054 
00069    class DT_DLL_VLUTIL DtHashlist
00070    {
00071    protected:
00072 
00076       static const int theDfltNumBuckets;
00077 
00078    public:
00079 
00082       DtHashlist(int numBuckets = theDfltNumBuckets);
00083 
00086       DtHashlist(DtList* list, int numBuckets = theDfltNumBuckets);
00087 
00089       virtual ~DtHashlist();
00090 
00096       DtHashlist(const DtHashlist& orig);
00097 
00101       DtHashlist& operator=(const DtHashlist& orig);
00102 
00110       virtual DtListItem* add(const DtBaseHashKey& key, 
00111                               void* data, void** oldData = NULL);
00112 
00115       virtual void* remove(const DtBaseHashKey& key);
00116 
00118       virtual void* lookup(const DtBaseHashKey& key) const;
00119       virtual void* operator[] (const DtBaseHashKey& key) const;
00120 
00123       virtual const DtList* list() const;
00124 
00126       virtual void print() const;
00127 
00130       virtual const DtList* keys() const;
00131 
00133       virtual void empty();
00134 
00138       virtual void setFromOther(const DtHashlist& orig);
00139 
00140    protected:
00141 
00143       virtual DtListItem* itemLookup(const DtBaseHashKey& key) const;
00144 
00146       virtual DtList& bucketFromHashKey(const DtBaseHashKey& key) const;
00147 
00149       virtual DtListItem* bucketItemLookup(const DtBaseHashKey& key) const;
00150 
00151    protected:
00152 
00153       int myNumBuckets;
00154       const bool myListIsMine;
00155 
00158       DtList* myList;
00159 
00161       DtList* myBuckets;
00162 
00164       DtList myKeys;
00165 
00166    };
00167 
00169    typedef DtHashlist DtHashList;
00170 
00172    inline void* DtHashlist::operator[] (const DtBaseHashKey& key) const
00173    {
00174       return lookup(key);
00175    }
00176 
00177 #ifdef DtUSE_UTILITIES_NAMESPACE
00178 } 
00179 #endif
00180 

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)