diff --git a/headers/private/shared/OpenHashTable.h b/headers/private/shared/OpenHashTable.h index dadd48a98e..94121008f6 100644 --- a/headers/private/shared/OpenHashTable.h +++ b/headers/private/shared/OpenHashTable.h @@ -49,9 +49,13 @@ All rights reserved. #include // don't include -#define ASSERT(E) (void)0 -#define TRESPASS() (void)0 - +#ifndef ASSERT +# define ASSERT(E) (void)0 +#endif +#ifndef TRESPASS +# define TRESPASS() (void)0 +#endif + namespace BPrivate { template @@ -89,17 +93,17 @@ public: // it is up to the subclass of OpenHashTable to supply // elementVector ~OpenHashTable(); - + bool InitCheck() const; void SetElementVector(ElementVec *elementVector); - + Element *FindFirst(uint32 elementHash) const; Element *Add(uint32 elementHash); - + void Remove(Element *element, bool dontRehash = false); void RemoveAll(); - + // when calling Add, any outstanding element pointer may become // invalid; to deal with this, get the element index and restore // it after the add @@ -116,7 +120,7 @@ protected: private: bool _RehashIfNeeded(); bool _Rehash(); - + int32 fArraySize; int32 fInitialSize; int32 fElementCount; @@ -189,7 +193,7 @@ OpenHashTable::InitCheck() const } template -int32 +int32 OpenHashTable::OptimalSize(int32 minSize) { for (int32 index = 0; ; index++) @@ -207,12 +211,12 @@ OpenHashTable::FindFirst(uint32 hash) const hash %= fArraySize; if (fHashArray[hash] < 0) return 0; - + return &fElementVector->At(fHashArray[hash]); } template -int32 +int32 OpenHashTable::ElementIndex(const Element *element) const { return fElementVector->IndexOf(*element); @@ -226,21 +230,21 @@ OpenHashTable::ElementAt(int32 index) const } template -int32 +int32 OpenHashTable::ArraySize() const { return fArraySize; } template -int32 +int32 OpenHashTable::VectorSize() const { return fElementVector->Size(); } template -int32 +int32 OpenHashTable::CountElements() const { return fElementCount; @@ -264,7 +268,7 @@ OpenHashTable::Add(uint32 hash) } template -void +void OpenHashTable::Remove(Element *element, bool dontRehash) { if (!dontRehash) @@ -287,7 +291,7 @@ OpenHashTable::Remove(Element *element, bool dontRehash) TRESPASS(); return; } - + if (&fElementVector->At(next) == element) { fElementVector->At(index).fNext = element->fNext; fElementVector->Remove(next); @@ -299,7 +303,7 @@ OpenHashTable::Remove(Element *element, bool dontRehash) } template -void +void OpenHashTable::RemoveAll() { for (int32 i = 0; fElementCount > 0 && i < fArraySize; i++) { @@ -317,7 +321,7 @@ OpenHashTable::RemoveAll() } template -void +void OpenHashTable::SetElementVector(ElementVec *elementVector) { fElementVector = elementVector; @@ -419,18 +423,18 @@ OpenHashElementArray::At(int32 index) const } template -int32 +int32 OpenHashElementArray::IndexOf(const Element &element) const { int32 result = &element - fData; if (result < 0 || result > fSize) return -1; - + return result; } template -int32 +int32 OpenHashElementArray::Size() const { return fSize; @@ -460,7 +464,7 @@ OpenHashElementArray::Add() int32 index = fNextFree; if (fNextDeleted >= 0) { index = fNextDeleted; - fNextDeleted = At(index).fNext; + fNextDeleted = At(index).fNext; } else if (fNextFree >= fSize - 1) { int32 newSize = fSize + kGrowChunk; /* @@ -486,11 +490,11 @@ OpenHashElementArray::Add() // call placement new to initialize the element properly ASSERT(At(index).fNext == -1); - return &At(index); + return &At(index); } template -void +void OpenHashElementArray::Remove(int32 index) { // delete by chaining empty elements in a single linked