Adapt to better suit wrapper's needs. Not part of default build. a=leaf.

This commit is contained in:
Peter.VanderBeken%pandora.be 2000-08-26 04:06:39 +00:00
Родитель aa39d2fac9
Коммит c2771d7682
2 изменённых файлов: 41 добавлений и 5 удалений

Просмотреть файл

@ -63,9 +63,13 @@ HashTable::~HashTable()
//
//Compute the bin from the Hash value, and store the object in the table
//
#ifdef MOZ_XSL
void HashTable::add(MITREObject* obj, void* hashValue)
#else
void HashTable::add(MITREObject* obj, Int32 hashValue)
#endif
{
Int32 bin = hashValue % HASHTABLE_SIZE;
Int32 bin = (Int32)hashValue % HASHTABLE_SIZE;
HashItem* newHashItem = new HashItem;
HashItem* existingItem = NULL;
@ -100,7 +104,11 @@ void HashTable::add(MITREObject* obj, Int32 hashValue)
//
//Locate the object specified by the hashValue
//
#ifdef MOZ_XSL
MITREObject* HashTable::retrieve(void* hashValue)
#else
MITREObject* HashTable::retrieve(Int32 hashValue)
#endif
{
HashItem* searchValue = retrieveHashItem(hashValue);
@ -114,9 +122,13 @@ MITREObject* HashTable::retrieve(Int32 hashValue)
//Locate the object specified by the hashValue, remove it from the table
//and return the orriginal object to the caller
//
#ifdef MOZ_XSL
MITREObject* HashTable::remove(void* hashValue)
#else
MITREObject* HashTable::remove(Int32 hashValue)
#endif
{
Int32 bin = hashValue % HASHTABLE_SIZE;
Int32 bin = (Int32)hashValue % HASHTABLE_SIZE;
MITREObject* returnObj = NULL;
HashItem* searchItem = table[bin];
@ -145,9 +157,13 @@ MITREObject* HashTable::remove(Int32 hashValue)
}
}
HashTable::HashItem* HashTable::retrieveHashItem(Int32 hashValue)
#ifdef MOZ_XSL
HashTable::HashItem* HashTable::retrieveHashItem(void* hashValue)
#else
HashTable::HashItem* HashTable::retrieveHashItem(Int32 hashValue)
#endif
{
Int32 bin = hashValue % HASHTABLE_SIZE;
Int32 bin = (Int32)hashValue % HASHTABLE_SIZE;
HashItem* searchItem = NULL;
//Goto the calculated bin, and begin a linear search for the specified

Просмотреть файл

@ -52,27 +52,47 @@ class HashTable
//Added the provided object to the hash table. If the item already exists,
//replace it, and delete the old copy.
#ifdef MOZ_XSL
void add(MITREObject* obj, void* hashValue);
#else
void add(MITREObject* obj, Int32 hashValue);
#endif
//Locate and Retrieve the specified object based on the provided value.
#ifdef MOZ_XSL
MITREObject* retrieve(void* hashValue);
#else
MITREObject* retrieve(Int32 hashValue);
#endif
//Locate, Remove, and Return the specified object based on the provided value.
#ifdef MOZ_XSL
MITREObject* remove(void* hashValue);
#else
MITREObject* remove(Int32 hashValue);
#endif
private:
typedef struct _HashItem
{
_HashItem* prevItem;
_HashItem* nextItem;
#ifdef MOZ_XSL
void* hashValue;
#else
Int32 hashValue;
#endif
MITREObject* objPtr;
}HashItem;
HashItem* table[HASHTABLE_SIZE];
HashItem* retrieveHashItem(Int32 hashValue);
#ifdef MOZ_XSL
HashItem* retrieveHashItem(void* hashValue);
#else
HashItem* retrieveHashItem(Int32 hashValue);
#endif
};
#endif