From 325530e630c68c7c10a2f4339f5b43434fcd0329 Mon Sep 17 00:00:00 2001 From: sc Date: Tue, 28 Nov 2000 14:19:35 +0000 Subject: Incorporation into IvyLeague Ccu -> Ivl ccu -> ivl Smart pointers disappear (too dangerous) Imakefile disappears (Makefile now) An empty cplus_bugs.h has been created locally --- utils/HashTable.h | 191 ++++++++++++++++++++++++++---------------------------- 1 file changed, 93 insertions(+), 98 deletions(-) (limited to 'utils/HashTable.h') diff --git a/utils/HashTable.h b/utils/HashTable.h index 6cfda82..6586efe 100644 --- a/utils/HashTable.h +++ b/utils/HashTable.h @@ -17,86 +17,84 @@ #ifndef HashTable_H_ #define HashTable_H_ - #include "cplus_bugs.h" #include -class CcuAllocator; +class IvlAllocator; -typedef void CcuHashItem; +typedef void IvlHashItem; -class CcuHashCell { +class IvlHashCell { protected: -friend class CcuHashTable; -friend class CcuHashCellIter; -static CcuAllocator* HashCellMem; +friend class IvlHashTable; +friend class IvlHashCellIter; +static IvlAllocator* HashCellMem; static void ClassInit (); const void* Key; /* hash key */ - CcuHashItem* Info; /* data */ - CcuHashCell* Next; /* synonyms */ + IvlHashItem* Info; /* data */ + IvlHashCell* Next; /* synonyms */ -inline CcuHashCell (const void* k, CcuHashCell* n) : Key (k), Info (0), Next (n) {} +inline IvlHashCell (const void* k, IvlHashCell* n) : Key (k), Info (0), Next (n) {} public: -inline void SetInfo (CcuHashItem* p) { Info = p; } -inline CcuHashItem* GetInfo () const { return Info; } +inline void SetInfo (IvlHashItem* p) { Info = p; } +inline IvlHashItem* GetInfo () const { return Info; } inline const void* GetKey () const { return Key; } void* operator new (size_t); void operator delete (void*); }; -class CcuHashCellRef { -friend class CcuHashTable; +class IvlHashCellRef { +friend class IvlHashTable; protected: - const CcuHashTable& Table; + const IvlHashTable& Table; const void* Key; -inline CcuHashCellRef (const CcuHashTable& t, const void* key) : Table (t), Key (key) {} +inline IvlHashCellRef (const IvlHashTable& t, const void* key) : Table (t), Key (key) {} #ifdef CPLUS_BUG1 -inline CcuHashCellRef (const CcuHashCellRef& t) : Table (t.Table), Key (t.Key) {} +inline IvlHashCellRef (const IvlHashCellRef& t) : Table (t.Table), Key (t.Key) {} #endif public: - CcuHashItem* operator = (CcuHashItem*); - operator CcuHashItem* (); + IvlHashItem* operator = (IvlHashItem*); + operator IvlHashItem* (); }; - typedef unsigned int (*HASH_F) (const void*, int); typedef int (*HCMP_F) (const void*, const void*); typedef void* (*HCP_F) (const void*); typedef void (*HDEL_F) (const void*); -class CcuHashTable { +class IvlHashTable { private: -friend class CcuHashCellIter; -friend class CcuHashCellRef; +friend class IvlHashCellIter; +friend class IvlHashCellRef; protected : - CcuHashCell** Table; + IvlHashCell** Table; unsigned int Size; HASH_F Hash; HCP_F Copy; HDEL_F Delete; HCMP_F Compare; - CcuHashCell** HashKey (const void*) const; - CcuHashCell* FindCell (CcuHashCell**, const void*) const; - CcuHashCell* AddCell (CcuHashCell**, const void*) const; + IvlHashCell** HashKey (const void*) const; + IvlHashCell* FindCell (IvlHashCell**, const void*) const; + IvlHashCell* AddCell (IvlHashCell**, const void*) const; public: static unsigned int HashPtr (const void*, int); - CcuHashTable (unsigned int, HASH_F = 0, HCP_F = 0, HDEL_F = 0, HCMP_F = 0); - CcuHashTable (const CcuHashTable&); - ~CcuHashTable (); - CcuHashCell* Add (const void*, int* = 0); - CcuHashCell* Get (const void*); - CcuHashItem* Remove (const void*, int* = 0); + IvlHashTable (unsigned int, HASH_F = 0, HCP_F = 0, HDEL_F = 0, HCMP_F = 0); + IvlHashTable (const IvlHashTable&); + ~IvlHashTable (); + IvlHashCell* Add (const void*, int* = 0); + IvlHashCell* Get (const void*); + IvlHashItem* Remove (const void*, int* = 0); void Clear (); void Resize (int); inline int GetSize () const { return Size; } - CcuHashCellRef operator [] (const void*) const; + IvlHashCellRef operator [] (const void*) const; #ifdef TUNE void HashStats (); @@ -104,127 +102,124 @@ inline int GetSize () const { return Size; } #endif }; -class CcuDictionnary : public CcuHashTable { +class IvlDictionnary : public IvlHashTable { protected: static void* CopyString (const void*); static void DeleteString (const void*); static int CompareString (const void*, const void*); - public: - CcuDictionnary (int size, HASH_F = 0); - ~CcuDictionnary (); + IvlDictionnary (int size, HASH_F = 0); + ~IvlDictionnary (); void KeyCopy (int); static unsigned int HashString (const void*, int); }; - -class CcuHashCellIter { +class IvlHashCellIter { public: enum hashiter_status { Normal, StartOfTable, EndOfTable, BadTable }; protected: - const CcuHashTable& TheTable; + const IvlHashTable& TheTable; int CurIndex; - CcuHashCell* CurCell; + IvlHashCell* CurCell; public: -inline CcuHashCellIter (const CcuHashTable& t) : TheTable (t) { CurIndex = -1; CurCell = 0; } -inline ~CcuHashCellIter () {} +inline IvlHashCellIter (const IvlHashTable& t) : TheTable (t) { CurIndex = -1; CurCell = 0; } +inline ~IvlHashCellIter () {} inline void Reset () { CurCell = 0; CurIndex = -1; } - CcuHashCellIter& operator ++ (); + IvlHashCellIter& operator ++ (); #ifndef CPLUS_BUG16 - CcuHashCellIter operator ++ (int); + IvlHashCellIter operator ++ (int); #endif -inline CcuHashCell* operator * () const { return CurCell; } +inline IvlHashCell* operator * () const { return CurCell; } hashiter_status GetStatus () const; inline operator int () const { return CurCell != 0; } }; -class CcuHashIter : public CcuHashCellIter { +class IvlHashIter : public IvlHashCellIter { public: -inline CcuHashIter (const CcuHashTable& t) : CcuHashCellIter (t) { } -inline ~CcuHashIter () {} +inline IvlHashIter (const IvlHashTable& t) : IvlHashCellIter (t) { } +inline ~IvlHashIter () {} -inline CcuHashIter& operator ++ () { return (CcuHashIter&)(this->CcuHashCellIter::operator ++ ()); } -inline CcuHashItem* operator * () const { return CurCell ? CurCell->GetInfo () : 0; } +inline IvlHashIter& operator ++ () { return (IvlHashIter&)(this->IvlHashCellIter::operator ++ ()); } +inline IvlHashItem* operator * () const { return CurCell ? CurCell->GetInfo () : 0; } }; #ifndef CPLUS_BUG19 -template class CcuHashTableOf; -template class CcuDictionnaryOf; +template class IvlHashTableOf; +template class IvlDictionnaryOf; -template class CcuHashCellOf : public CcuHashCell { +template class IvlHashCellOf : public IvlHashCell { protected: -inline CcuHashCellOf (const void* k, CcuHashCellOf* n) : CcuHashCell (k, n) {} +inline IvlHashCellOf (const void* k, IvlHashCellOf* n) : IvlHashCell (k, n) {} public: -inline void SetInfo (ITEM* p) { CcuHashCell::SetInfo (p); } -inline ITEM* GetInfo () const { return (ITEM*) CcuHashCell::GetInfo (); } +inline void SetInfo (ITEM* p) { IvlHashCell::SetInfo (p); } +inline ITEM* GetInfo () const { return (ITEM*) IvlHashCell::GetInfo (); } }; -template class CcuHashCellRefOf : public CcuHashCellRef { +template class IvlHashCellRefOf : public IvlHashCellRef { public: -inline CcuHashCellRefOf (const CcuHashTableOf& t, const void* key) : CcuHashCellRef (t, key) {} +inline IvlHashCellRefOf (const IvlHashTableOf& t, const void* key) : IvlHashCellRef (t, key) {} #ifdef CPLUS_BUG1 -inline CcuHashCellRefOf (const CcuHashCellRefOf& t) : CcuHashCellRef (t) {} +inline IvlHashCellRefOf (const IvlHashCellRefOf& t) : IvlHashCellRef (t) {} #endif -inline ITEM* operator = (ITEM* it) { return (ITEM*) (CcuHashCellRef::operator = (it)); } -inline operator ITEM* () { return (ITEM*) (CcuHashCellRef::operator CcuHashItem* ()); } +inline ITEM* operator = (ITEM* it) { return (ITEM*) (IvlHashCellRef::operator = (it)); } +inline operator ITEM* () { return (ITEM*) (IvlHashCellRef::operator IvlHashItem* ()); } }; - -template class CcuHashTableOf : public CcuHashTable { +template class IvlHashTableOf : public IvlHashTable { public: -inline CcuHashTableOf (unsigned int size, HASH_F hash = 0, HCP_F cp = 0, HDEL_F del = 0, HCMP_F cmp= 0) : CcuHashTable (size, hash, cp, del, cmp) {} -inline ~CcuHashTableOf () {} -inline CcuHashCellOf* Add (const void* key, int* found = 0) { return (CcuHashCellOf*) CcuHashTable::Add (key, found); } -inline CcuHashCellOf* Get (const void* key) { return (CcuHashCellOf*) CcuHashTable::Get (key); } -inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) CcuHashTable::Remove (key, found); } -inline CcuHashCellRefOf operator [] (const void* key) const { return CcuHashCellRefOf (*this, key); } +inline IvlHashTableOf (unsigned int size, HASH_F hash = 0, HCP_F cp = 0, HDEL_F del = 0, HCMP_F cmp= 0) : IvlHashTable (size, hash, cp, del, cmp) {} +inline ~IvlHashTableOf () {} +inline IvlHashCellOf* Add (const void* key, int* found = 0) { return (IvlHashCellOf*) IvlHashTable::Add (key, found); } +inline IvlHashCellOf* Get (const void* key) { return (IvlHashCellOf*) IvlHashTable::Get (key); } +inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) IvlHashTable::Remove (key, found); } +inline IvlHashCellRefOf operator [] (const void* key) const { return IvlHashCellRefOf (*this, key); } }; -template class CcuDictionnaryOf : public CcuDictionnary { +template class IvlDictionnaryOf : public IvlDictionnary { public: -inline CcuDictionnaryOf (unsigned int size, HASH_F hash = 0) : CcuDictionnary (size, hash) {} -inline ~CcuDictionnaryOf () {} -inline CcuHashCellOf* Add (const void* key, int* found = 0) { return (CcuHashCellOf*) CcuDictionnary::Add (key, found); } -inline CcuHashCellOf* Get (const void* key) { return (CcuHashCellOf*) CcuDictionnary::Get (key); } -inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) CcuDictionnary::Remove (key, found); } -inline operator const CcuHashTableOf& () const { return *(const CcuHashTableOf*) this; } -inline CcuHashCellRefOf operator [] (const char* key) const { return CcuHashCellRefOf (*(const CcuHashTableOf*)this, key); } +inline IvlDictionnaryOf (unsigned int size, HASH_F hash = 0) : IvlDictionnary (size, hash) {} +inline ~IvlDictionnaryOf () {} +inline IvlHashCellOf* Add (const void* key, int* found = 0) { return (IvlHashCellOf*) IvlDictionnary::Add (key, found); } +inline IvlHashCellOf* Get (const void* key) { return (IvlHashCellOf*) IvlDictionnary::Get (key); } +inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) IvlDictionnary::Remove (key, found); } +inline operator const IvlHashTableOf& () const { return *(const IvlHashTableOf*) this; } +inline IvlHashCellRefOf operator [] (const char* key) const { return IvlHashCellRefOf (*(const IvlHashTableOf*)this, key); } }; -template class CcuHashedArrayOf : public CcuHashTable { +template class IvlHashedArrayOf : public IvlHashTable { public: -inline CcuHashedArrayOf (unsigned int size, HASH_F hash = 0) : CcuHashTable (size, hash) {} -inline ~CcuHashedArrayOf () {} -inline CcuHashCellOf* Add (int key, int* found = 0) { return (CcuHashCellOf*) CcuHashTable::Add ((void*)key, found); } -inline CcuHashCellOf* Get (int key) { return (CcuHashCellOf*) CcuHashTable::Get ((void*)key); } -inline ITEM* Remove (int key, int* found = 0) { return (ITEM*) CcuHashTable::Remove ((void*) key, found); } -inline operator const CcuHashTableOf& () const { return *(const CcuHashTableOf*) this; } -inline CcuHashCellRefOf operator [] (int key) const { return CcuHashCellRefOf (*(const CcuHashTableOf*)this, (void*)key); } +inline IvlHashedArrayOf (unsigned int size, HASH_F hash = 0) : IvlHashTable (size, hash) {} +inline ~IvlHashedArrayOf () {} +inline IvlHashCellOf* Add (int key, int* found = 0) { return (IvlHashCellOf*) IvlHashTable::Add ((void*)key, found); } +inline IvlHashCellOf* Get (int key) { return (IvlHashCellOf*) IvlHashTable::Get ((void*)key); } +inline ITEM* Remove (int key, int* found = 0) { return (ITEM*) IvlHashTable::Remove ((void*) key, found); } +inline operator const IvlHashTableOf& () const { return *(const IvlHashTableOf*) this; } +inline IvlHashCellRefOf operator [] (int key) const { return IvlHashCellRefOf (*(const IvlHashTableOf*)this, (void*)key); } }; -template class CcuHashIterOf : public CcuHashIter { +template class IvlHashIterOf : public IvlHashIter { public: -inline CcuHashIterOf (const CcuHashTableOf& t) : CcuHashIter (t) { } -inline ~CcuHashIterOf () {} -inline CcuHashIterOf& operator ++ () { return (CcuHashIterOf&)(this->CcuHashIter::operator ++ ()); } -inline ITEM* operator * () const { return (ITEM*) (CcuHashIter::operator * ()); } +inline IvlHashIterOf (const IvlHashTableOf& t) : IvlHashIter (t) { } +inline ~IvlHashIterOf () {} +inline IvlHashIterOf& operator ++ () { return (IvlHashIterOf&)(this->IvlHashIter::operator ++ ()); } +inline ITEM* operator * () const { return (ITEM*) (IvlHashIter::operator * ()); } }; -template class CcuHashCellIterOf : public CcuHashCellIter { +template class IvlHashCellIterOf : public IvlHashCellIter { public: -inline CcuHashCellIterOf (const CcuHashTableOf& t) : CcuHashCellIter (t) { } -inline ~CcuHashCellIterOf () {} -inline CcuHashCellIterOf& operator ++ () { return (CcuHashCellIterOf&)(this->CcuHashCellIter::operator ++ ()); } +inline IvlHashCellIterOf (const IvlHashTableOf& t) : IvlHashCellIter (t) { } +inline ~IvlHashCellIterOf () {} +inline IvlHashCellIterOf& operator ++ () { return (IvlHashCellIterOf&)(this->IvlHashCellIter::operator ++ ()); } #ifndef CPLUS_BUG16 -inline CcuHashCellIterOf operator ++ (int i) { return *(CcuHashCellIterOf*)&(this->CcuHashCellIter::operator ++ (i)); } +inline IvlHashCellIterOf operator ++ (int i) { return *(IvlHashCellIterOf*)&(this->IvlHashCellIter::operator ++ (i)); } #endif -inline CcuHashCellOf* operator * () const { return (CcuHashCellOf*) (CcuHashCellIter::operator * ()); } +inline IvlHashCellOf* operator * () const { return (IvlHashCellOf*) (IvlHashCellIter::operator * ()); } }; #endif /* CPLUS_BUG19 */ -- cgit v1.1