75 {
return (
UPInt) data; }
94 h = (h << 16) + (h << 6) - h + (
UPInt)data[size];
101 unsigned char* p = (
unsigned char*) &data;
102 int size =
sizeof(C);
114 template<
class C,
class HashF>
149 template<
class C,
class HashF>
191 template<
class C,
class HashF = FixedSizeHash<C>,
192 class AltHashF = HashF,
193 class Allocator = ContainerAllocator<C>,
194 class Entry = HashsetCachedEntry<C, HashF> >
272 UPInt hashValue = HashF()(key);
280 E(index).Value = key;
290 inline void Add(
const CRef& key)
292 UPInt hashValue = HashF()(key);
303 UPInt hashValue = AltHashF()(key);
306 Entry* e = &
E(index);
314 SPInt prevIndex = -1;
320 index = e->NextInChain;
327 if (naturalIndex == index)
330 if (!e->IsEndOfChain())
332 Entry* enext = &
E(e->NextInChain);
334 new (e) Entry(*enext);
342 E(prevIndex).NextInChain = e->NextInChain;
366 return &
E(index).Value;
371 const C*
Get(
const K& key)
const
375 return &
E(index).Value;
385 return &
E(index).Value;
394 return &
E(index).Value;
405 *pval =
E(index).Value;
451 UPInt newRawSize = (newSize * 5) / 4;
459 #if (OVR_CC_MSVC < 1300)
460 # pragma warning(disable : 4284)
507 return ! (*
this == it);
580 UPInt hashValue = AltHashF()(key);
583 Entry* e = &phash->
E(index);
591 SPInt prevIndex = -1;
593 while ((e->GetCachedHash(phash->
pTable->
SizeMask) != (
UPInt)naturalIndex) || !(e->Value == key))
597 index = e->NextInChain;
600 e = &phash->
E(index);
606 if (naturalIndex == index)
609 if (!e->IsEndOfChain())
611 Entry* enext = &phash->
E(e->NextInChain);
613 new (e) Entry(*enext);
622 phash->
E(prevIndex).NextInChain = e->NextInChain;
650 while (i0 <= pTable->SizeMask &&
E(i0).
IsEmpty())
715 const Entry* e = &
E(index);
725 if (e->GetCachedHash(
pTable->
SizeMask) == hashValue && e->Value == key)
735 index = e->NextInChain;
736 if (index == (
UPInt)-1)
756 Entry* naturalEntry = &(
E(index));
758 if (naturalEntry->IsEmpty())
761 new (naturalEntry) Entry(key, -1);
769 }
while(!
E(blankIndex).IsEmpty());
771 Entry* blankEntry = &
E(blankIndex);
778 new (blankEntry) Entry(*naturalEntry);
781 naturalEntry->Value = key;
782 naturalEntry->NextInChain = blankIndex;
795 Entry* e = &
E(collidedIndex);
796 if (e->NextInChain == index)
799 new (blankEntry) Entry(*naturalEntry);
800 e->NextInChain = blankIndex;
803 collidedIndex = e->NextInChain;
808 naturalEntry->Value = key;
809 naturalEntry->NextInChain = -1;
814 naturalEntry->SetCachedHash(hashValue);
822 return *(((Entry*) (
pTable + 1)) + index);
827 return *(((Entry*) (
pTable + 1)) + index);
854 newSize =
UPInt(1) << bits;
858 newHash.
pTable = (TableType*)
860 sizeof(TableType) +
sizeof(Entry) * newSize);
869 for (i = 0; i < newSize; i++)
870 newHash.
E(i).NextInChain = -2;
878 if (e->IsEmpty() ==
false)
881 newHash.
Add(e->Value);
909 template<
class C,
class HashF = FixedSizeHash<C>,
910 class AltHashF = HashF,
911 class Allocator = ContainerAllocator<C>,
912 class Entry = HashsetCachedEntry<C, HashF> >
936 inline void Add(
const CRef& key)
958 template<
class C,
class HashF = FixedSizeHash<C>,
959 class AltHashF = HashF,
960 class Allocator = ContainerAllocator<C> >
986 template<
class C,
class U,
class HashF>
1009 operator const C& ()
const {
return *
pFirst; }
1048 template<
class C,
class HashF>
1082 template<
class C,
class HashF>
1117 template<
class C,
class U,
1118 class HashF = FixedSizeHash<C>,
1119 class Allocator = ContainerAllocator<C>,
1121 class Entry = HashsetCachedNodeEntry<HashNode, typename HashNode::NodeHashF>,
1122 class Container = HashSet<HashNode,
typename HashNode::NodeHashF,
1123 typename HashNode::NodeAltHashF, Allocator,
1151 inline void Set(
const C& key,
const U& value)
1156 inline void Add(
const C& key,
const U& value)
1165 mHash.RemoveAlt(key);
1170 mHash.RemoveAlt(key);
1177 bool Get(
const C& key, U* pvalue)
const
1208 return p ? &p->
Second : 0;
1210 inline const U*
Get(
const C& key)
const
1213 return p ? &p->
Second : 0;
1220 return p ? &p->
Second : 0;
1226 return p ? &p->
Second : 0;
1255 template<
class C,
class U,
class HashF = FixedSizeHash<C>,
class Allocator = ContainerAllocator<C> >
1257 :
public Hash<C, U, HashF, Allocator, HashNode<C,U,HashF>,
1258 HashsetNodeEntry<HashNode<C,U,HashF>, typename HashNode<C,U,HashF>::NodeHashF> >
1278 template<
class C,
class U,
class Allocator = ContainerAllocator<C>,
class HashF = IdentityHash<C> >
1298 #ifdef OVR_DEFINE_NEW
1299 #define new OVR_DEFINE_NEW
void Remove(const CRef &key)
const C * Get(const K &key) const
static OVR_FORCE_INLINE UPInt SDBM_Hash(const void *data_in, UPInt size, UPInt seed=5381)
ConstIterator FindAlt(const K &key) const
void Add(const C &key, const U &value)
UPInt GetCachedHash(UPInt maskValue) const
HashsetNodeEntry(const HashsetNodeEntry &e)
HashSetBase< C, HashF, AltHashF, Allocator, Entry > BaseType
HashsetCachedNodeEntry(const C &key, SPInt next)
HashSetBase(int sizeHint)
HashSetUncached(const SelfType &src)
void Add(const CRef &key)
SPInt findIndex(const K &key) const
const C * GetAlt(const K &key) const
HashsetCachedNodeEntry(const HashsetCachedNodeEntry &e)
HashSetUncached< C, HashF, AltHashF, Allocator > SelfType
void operator=(const NodeRef &src)
bool IsEndOfChain() const
Hash(const SelfType &src)
HashsetCachedEntry(const C &key, SPInt next)
Hash< C, U, HashF, Allocator, HashNode< C, U, HashF >, HashsetNodeEntry< HashNode< C, U, HashF >, typename HashNode< C, U, HashF >::NodeHashF > > BaseType
Iterator Find(const K &key)
UPInt operator()(const K &data) const
HashUncached(int sizeHint)
friend struct ConstIterator
void SetCapacity(UPInt newSize)
void operator=(const SelfType &src)
void operator=(const SelfType &src)
UPInt operator()(const C &data) const
NodeRef(const C &f, const U &s)
const C & operator*() const
void setRawCapacity(UPInt newSize)
const U * GetAlt(const K &key) const
void Set(const C &key, const U &value)
HashIdentity(const SelfType &src)
Iterator FindAlt(const K &key)
bool GetAlt(const K &key, U *pvalue) const
HashsetEntry(const C &key, SPInt next)
void operator=(const SelfType &src)
UPInt GetCachedHash(UPInt maskValue) const
void Remove(const C &key)
ConstIterator Find(const K &key) const
bool GetAlt(const K &key, C *pval) const
ConstIterator(const SelfType *h, SPInt index)
ConstIterator Find(const C &key) const
HashSet< C, HashF, AltHashF, Allocator, Entry > SelfType
UByte UpperBit(UPInt val)
void operator=(const SelfType &src)
void RemoveAlt(const K &key)
HashSet< C, HashF, AltHashF, Allocator, HashsetEntry< C, HashF > > BaseType
bool operator!=(const ConstIterator &it) const
void SetCachedHash(UPInt hashValue)
HashsetNodeEntry(const typename C::NodeRef &keyRef, SPInt next)
HashUncached(const SelfType &src)
const Entry & E(UPInt index) const
void RemoveAlt(const K &key)
#define OVR_MEMORY_REDEFINE_NEW(class_name)
HashUncached< C, U, HashF, Allocator > BaseType
HashsetEntry(const HashsetEntry &e)
const U * Get(const C &key) const
void operator=(const SelfType &src)
HashIdentity< C, U, Allocator, HashF > SelfType
HashNode(const NodeRef &src)
Iterator FindAlt(const K &key)
Container::ConstIterator ConstIterator
UPInt operator()(const C &data) const
HashNode< C, U, HashF > SelfType
void Add(const CRef &key)
HashNode(const HashNode &src)
HashsetCachedNodeEntry(const typename C::NodeRef &keyRef, SPInt next)
void SetCachedHash(UPInt)
void RemoveAlt(const K &key)
HashSet(const SelfType &src)
void Set(const CRef &key)
SPInt findIndexAlt(const K &key) const
NodeRef(const NodeRef &src)
void SetCapacity(UPInt newSize)
void SetCapacity(UPInt newSize)
SPInt findIndexCore(const K &key, UPInt hashValue) const
void SetCachedHash(UPInt hashValue)
ConstIterator Begin() const
Container::Iterator Iterator
virtual void * Alloc(UPInt size)=0
ConstIterator Begin() const
ConstIterator FindAlt(const K &key) const
UPInt operator()(const K &data) const
bool IsEndOfChain() const
Iterator Find(const C &key)
void add(const CRef &key, UPInt hashValue)
Iterator(SelfType *h, SPInt i0)
static UPInt CalcHash(const K &data)
int char * index(const char *__s, int __c) __THROW __attribute_pure__ __nonnull((1))
HashsetCachedEntry(const HashsetCachedEntry &e)
void SetCachedHash(UPInt hashValue)
bool operator==(const K &src) const
void Assign(const SelfType &src)
bool IsEndOfChain() const
UPInt GetCachedHash(UPInt maskValue) const
HashUncached< C, U, HashF, Allocator > SelfType
ConstIterator End() const
virtual void Free(void *p)=0
void Set(const CRef &key)
HashSetBase(const SelfType &src)
const C * operator->() const
HashIdentity(int sizeHint)
ConstIterator End() const
UPInt GetCachedHash(UPInt maskValue) const
const SelfType * GetContainer() const
HashsetNodeEntry(const C &key, SPInt next)
bool operator==(const ConstIterator &it) const
HashSetUncached(int sizeHint)
bool Get(const C &key, U *pvalue) const
bool IsEndOfChain() const