summaryrefslogtreecommitdiff
path: root/utils/HashTable.h
diff options
context:
space:
mode:
authorsc2000-11-28 14:19:35 +0000
committersc2000-11-28 14:19:35 +0000
commit325530e630c68c7c10a2f4339f5b43434fcd0329 (patch)
tree8e655f6002598176ed0e9e5e0ba3bcb0971c434d /utils/HashTable.h
parentb8af7905fd61ce5cb2c94da78ccc9e051f9ceddc (diff)
downloadivy-league-325530e630c68c7c10a2f4339f5b43434fcd0329.zip
ivy-league-325530e630c68c7c10a2f4339f5b43434fcd0329.tar.gz
ivy-league-325530e630c68c7c10a2f4339f5b43434fcd0329.tar.bz2
ivy-league-325530e630c68c7c10a2f4339f5b43434fcd0329.tar.xz
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
Diffstat (limited to 'utils/HashTable.h')
-rw-r--r--utils/HashTable.h191
1 files changed, 93 insertions, 98 deletions
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 <sys/types.h>
-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 ITEM> class CcuHashTableOf;
-template <class ITEM> class CcuDictionnaryOf;
+template <class ITEM> class IvlHashTableOf;
+template <class ITEM> class IvlDictionnaryOf;
-template <class ITEM> class CcuHashCellOf : public CcuHashCell {
+template <class ITEM> class IvlHashCellOf : public IvlHashCell {
protected:
-inline CcuHashCellOf (const void* k, CcuHashCellOf<ITEM>* n) : CcuHashCell (k, n) {}
+inline IvlHashCellOf (const void* k, IvlHashCellOf<ITEM>* 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 ITEM> class CcuHashCellRefOf : public CcuHashCellRef {
+template <class ITEM> class IvlHashCellRefOf : public IvlHashCellRef {
public:
-inline CcuHashCellRefOf (const CcuHashTableOf<ITEM>& t, const void* key) : CcuHashCellRef (t, key) {}
+inline IvlHashCellRefOf (const IvlHashTableOf<ITEM>& t, const void* key) : IvlHashCellRef (t, key) {}
#ifdef CPLUS_BUG1
-inline CcuHashCellRefOf (const CcuHashCellRefOf<ITEM>& t) : CcuHashCellRef (t) {}
+inline IvlHashCellRefOf (const IvlHashCellRefOf<ITEM>& 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 ITEM> class CcuHashTableOf : public CcuHashTable {
+template <class ITEM> 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<ITEM>* Add (const void* key, int* found = 0) { return (CcuHashCellOf<ITEM>*) CcuHashTable::Add (key, found); }
-inline CcuHashCellOf<ITEM>* Get (const void* key) { return (CcuHashCellOf<ITEM>*) CcuHashTable::Get (key); }
-inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) CcuHashTable::Remove (key, found); }
-inline CcuHashCellRefOf<ITEM> operator [] (const void* key) const { return CcuHashCellRefOf<ITEM> (*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<ITEM>* Add (const void* key, int* found = 0) { return (IvlHashCellOf<ITEM>*) IvlHashTable::Add (key, found); }
+inline IvlHashCellOf<ITEM>* Get (const void* key) { return (IvlHashCellOf<ITEM>*) IvlHashTable::Get (key); }
+inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) IvlHashTable::Remove (key, found); }
+inline IvlHashCellRefOf<ITEM> operator [] (const void* key) const { return IvlHashCellRefOf<ITEM> (*this, key); }
};
-template <class ITEM> class CcuDictionnaryOf : public CcuDictionnary {
+template <class ITEM> class IvlDictionnaryOf : public IvlDictionnary {
public:
-inline CcuDictionnaryOf (unsigned int size, HASH_F hash = 0) : CcuDictionnary (size, hash) {}
-inline ~CcuDictionnaryOf () {}
-inline CcuHashCellOf<ITEM>* Add (const void* key, int* found = 0) { return (CcuHashCellOf<ITEM>*) CcuDictionnary::Add (key, found); }
-inline CcuHashCellOf<ITEM>* Get (const void* key) { return (CcuHashCellOf<ITEM>*) CcuDictionnary::Get (key); }
-inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) CcuDictionnary::Remove (key, found); }
-inline operator const CcuHashTableOf<ITEM>& () const { return *(const CcuHashTableOf<ITEM>*) this; }
-inline CcuHashCellRefOf<ITEM> operator [] (const char* key) const { return CcuHashCellRefOf<ITEM> (*(const CcuHashTableOf<ITEM>*)this, key); }
+inline IvlDictionnaryOf (unsigned int size, HASH_F hash = 0) : IvlDictionnary (size, hash) {}
+inline ~IvlDictionnaryOf () {}
+inline IvlHashCellOf<ITEM>* Add (const void* key, int* found = 0) { return (IvlHashCellOf<ITEM>*) IvlDictionnary::Add (key, found); }
+inline IvlHashCellOf<ITEM>* Get (const void* key) { return (IvlHashCellOf<ITEM>*) IvlDictionnary::Get (key); }
+inline ITEM* Remove (const void* key, int* found = 0) { return (ITEM*) IvlDictionnary::Remove (key, found); }
+inline operator const IvlHashTableOf<ITEM>& () const { return *(const IvlHashTableOf<ITEM>*) this; }
+inline IvlHashCellRefOf<ITEM> operator [] (const char* key) const { return IvlHashCellRefOf<ITEM> (*(const IvlHashTableOf<ITEM>*)this, key); }
};
-template <class ITEM> class CcuHashedArrayOf : public CcuHashTable {
+template <class ITEM> class IvlHashedArrayOf : public IvlHashTable {
public:
-inline CcuHashedArrayOf (unsigned int size, HASH_F hash = 0) : CcuHashTable (size, hash) {}
-inline ~CcuHashedArrayOf () {}
-inline CcuHashCellOf<ITEM>* Add (int key, int* found = 0) { return (CcuHashCellOf<ITEM>*) CcuHashTable::Add ((void*)key, found); }
-inline CcuHashCellOf<ITEM>* Get (int key) { return (CcuHashCellOf<ITEM>*) CcuHashTable::Get ((void*)key); }
-inline ITEM* Remove (int key, int* found = 0) { return (ITEM*) CcuHashTable::Remove ((void*) key, found); }
-inline operator const CcuHashTableOf<ITEM>& () const { return *(const CcuHashTableOf<ITEM>*) this; }
-inline CcuHashCellRefOf<ITEM> operator [] (int key) const { return CcuHashCellRefOf<ITEM> (*(const CcuHashTableOf<ITEM>*)this, (void*)key); }
+inline IvlHashedArrayOf (unsigned int size, HASH_F hash = 0) : IvlHashTable (size, hash) {}
+inline ~IvlHashedArrayOf () {}
+inline IvlHashCellOf<ITEM>* Add (int key, int* found = 0) { return (IvlHashCellOf<ITEM>*) IvlHashTable::Add ((void*)key, found); }
+inline IvlHashCellOf<ITEM>* Get (int key) { return (IvlHashCellOf<ITEM>*) IvlHashTable::Get ((void*)key); }
+inline ITEM* Remove (int key, int* found = 0) { return (ITEM*) IvlHashTable::Remove ((void*) key, found); }
+inline operator const IvlHashTableOf<ITEM>& () const { return *(const IvlHashTableOf<ITEM>*) this; }
+inline IvlHashCellRefOf<ITEM> operator [] (int key) const { return IvlHashCellRefOf<ITEM> (*(const IvlHashTableOf<ITEM>*)this, (void*)key); }
};
-template <class ITEM> class CcuHashIterOf : public CcuHashIter {
+template <class ITEM> class IvlHashIterOf : public IvlHashIter {
public:
-inline CcuHashIterOf (const CcuHashTableOf<ITEM>& t) : CcuHashIter (t) { }
-inline ~CcuHashIterOf () {}
-inline CcuHashIterOf<ITEM>& operator ++ () { return (CcuHashIterOf<ITEM>&)(this->CcuHashIter::operator ++ ()); }
-inline ITEM* operator * () const { return (ITEM*) (CcuHashIter::operator * ()); }
+inline IvlHashIterOf (const IvlHashTableOf<ITEM>& t) : IvlHashIter (t) { }
+inline ~IvlHashIterOf () {}
+inline IvlHashIterOf<ITEM>& operator ++ () { return (IvlHashIterOf<ITEM>&)(this->IvlHashIter::operator ++ ()); }
+inline ITEM* operator * () const { return (ITEM*) (IvlHashIter::operator * ()); }
};
-template <class ITEM> class CcuHashCellIterOf : public CcuHashCellIter {
+template <class ITEM> class IvlHashCellIterOf : public IvlHashCellIter {
public:
-inline CcuHashCellIterOf (const CcuHashTableOf<ITEM>& t) : CcuHashCellIter (t) { }
-inline ~CcuHashCellIterOf () {}
-inline CcuHashCellIterOf<ITEM>& operator ++ () { return (CcuHashCellIterOf<ITEM>&)(this->CcuHashCellIter::operator ++ ()); }
+inline IvlHashCellIterOf (const IvlHashTableOf<ITEM>& t) : IvlHashCellIter (t) { }
+inline ~IvlHashCellIterOf () {}
+inline IvlHashCellIterOf<ITEM>& operator ++ () { return (IvlHashCellIterOf<ITEM>&)(this->IvlHashCellIter::operator ++ ()); }
#ifndef CPLUS_BUG16
-inline CcuHashCellIterOf<ITEM> operator ++ (int i) { return *(CcuHashCellIterOf<ITEM>*)&(this->CcuHashCellIter::operator ++ (i)); }
+inline IvlHashCellIterOf<ITEM> operator ++ (int i) { return *(IvlHashCellIterOf<ITEM>*)&(this->IvlHashCellIter::operator ++ (i)); }
#endif
-inline CcuHashCellOf<ITEM>* operator * () const { return (CcuHashCellOf<ITEM>*) (CcuHashCellIter::operator * ()); }
+inline IvlHashCellOf<ITEM>* operator * () const { return (IvlHashCellOf<ITEM>*) (IvlHashCellIter::operator * ()); }
};
#endif /* CPLUS_BUG19 */