3#include <Foundation/Algorithm/HashingUtils.h>
4#include <Foundation/Math/Math.h>
5#include <Foundation/Memory/AllocatorWrapper.h>
17template <
typename KeyType,
typename Hasher>
34 const KeyType&
Key()
const;
37 PL_ALWAYS_INLINE
const KeyType&
operator*()
const {
return Key(); }
53 plUInt32 m_uiCurrentIndex = 0;
54 plUInt32 m_uiCurrentCount = 0;
83 void Reserve(plUInt32 uiCapacity);
101 template <
typename CompatibleKeyType>
102 bool Insert(CompatibleKeyType&& key);
105 template <
typename CompatibleKeyType>
106 bool Remove(
const CompatibleKeyType& key);
112 template <
typename CompatibleKeyType>
144 template <
typename CompatibleKeyType>
149 plUInt32* m_pEntryFlags;
152 plUInt32 m_uiCapacity;
162 CAPACITY_ALIGNMENT = 32
165 void SetCapacity(plUInt32 uiCapacity);
167 void RemoveInternal(plUInt32 uiIndex);
169 template <
typename CompatibleKeyType>
170 plUInt32 FindEntry(
const CompatibleKeyType& key)
const;
172 template <
typename CompatibleKeyType>
173 plUInt32 FindEntry(plUInt32 uiHash,
const CompatibleKeyType& key)
const;
175 plUInt32 GetFlagsCapacity()
const;
176 plUInt32 GetFlags(plUInt32* pFlags, plUInt32 uiEntryIndex)
const;
177 void SetFlags(plUInt32 uiEntryIndex, plUInt32 uiFlags);
179 bool IsFreeEntry(plUInt32 uiEntryIndex)
const;
180 bool IsValidEntry(plUInt32 uiEntryIndex)
const;
181 bool IsDeletedEntry(plUInt32 uiEntryIndex)
const;
183 void MarkEntryAsFree(plUInt32 uiEntryIndex);
184 void MarkEntryAsValid(plUInt32 uiEntryIndex);
185 void MarkEntryAsDeleted(plUInt32 uiEntryIndex);
189template <
typename KeyType,
typename Hasher = plHashHelper<KeyType>,
typename AllocatorWrapper = plDefaultAllocatorWrapper>
209template <
typename KeyType,
typename Hasher>
215template <
typename KeyType,
typename Hasher>
221template <
typename KeyType,
typename Hasher>
227template <
typename KeyType,
typename Hasher>
233#include <Foundation/Containers/Implementation/HashSet_inl.h>
Base class for all memory allocators.
Definition Allocator.h:23
Const iterator.
Definition HashSet.h:23
bool IsValid() const
Checks whether this iterator points to a valid element.
Definition HashSet_inl.h:37
void operator++()
Shorthand for 'Next'.
Definition HashSet_inl.h:75
void Next()
Advances the iterator to the next element in the map. The iterator will not be valid anymore,...
Definition HashSet_inl.h:55
PL_ALWAYS_INLINE const KeyType & operator*() const
Returns the 'key' of the element that this iterator points to.
Definition HashSet.h:37
const KeyType & Key() const
Returns the 'key' of the element that this iterator points to.
Definition HashSet_inl.h:49
bool operator==(const typename plHashSetBase< KeyType, Hasher >::ConstIterator &rhs) const
Checks whether the two iterators point to the same element.
Definition HashSet_inl.h:43
Implementation of a hashset.
Definition HashSet.h:19
bool operator==(const plHashSetBase< KeyType, Hasher > &rhs) const
Compares this table to another table.
Definition HashSet_inl.h:185
bool Contains(const CompatibleKeyType &key) const
Returns if an entry with given key exists in the table.
plHashSetBase(plHashSetBase< KeyType, Hasher > &&rhs, plAllocator *pAllocator)
Moves data from an existing hashtable into this one.
void Clear()
Clears the table.
Definition HashSet_inl.h:254
bool Insert(CompatibleKeyType &&key)
Inserts the key. Returns whether the key was already existing.
Definition HashSet_inl.h:270
void Intersection(const plHashSetBase< KeyType, Hasher > &operand)
Makes this set the intersection of itself and the operand.
Definition HashSet_inl.h:425
plAllocator * GetAllocator() const
Returns the allocator that is used by this instance.
Definition HashSet_inl.h:453
void Compact()
Tries to compact the hashset to avoid wasting memory.
Definition HashSet_inl.h:224
void Union(const plHashSetBase< KeyType, Hasher > &operand)
Makes this set the union of itself and the operand.
Definition HashSet_inl.h:406
ConstIterator Remove(const ConstIterator &pos)
Erases the key at the given Iterator. Returns an iterator to the element after the given iterator.
~plHashSetBase()
Destructor.
Definition HashSet_inl.h:118
bool IsEmpty() const
Returns true, if the hashset does not contain any elements.
Definition HashSet_inl.h:248
ConstIterator Find(const CompatibleKeyType &key) const
Searches for key, returns a ConstIterator to it or an invalid iterator, if no such key is found....
bool ContainsSet(const plHashSetBase< KeyType, Hasher > &operand) const
Checks whether all keys of the given set are in the container.
Definition HashSet_inl.h:394
plHashSetBase(plAllocator *pAllocator)
Creates an empty hashset. Does not allocate any data yet.
Definition HashSet_inl.h:84
plUInt32 GetCount() const
Returns the number of active entries in the table.
Definition HashSet_inl.h:242
void Swap(plHashSetBase< KeyType, Hasher > &other)
Swaps this map with the other one.
Definition HashSet_inl.h:663
void Reserve(plUInt32 uiCapacity)
Expands the hashset by over-allocating the internal storage so that the load factor is lower or equal...
Definition HashSet_inl.h:206
void Difference(const plHashSetBase< KeyType, Hasher > &operand)
Makes this set the difference of itself and the operand, i.e. subtracts operand.
Definition HashSet_inl.h:416
void operator=(plHashSetBase< KeyType, Hasher > &&rhs)
Moves data from an existing hashset into this one.
plUInt64 GetHeapMemoryUsage() const
Returns the amount of bytes that are currently allocated on the heap.
Definition HashSet_inl.h:459
ConstIterator GetIterator() const
Returns a constant Iterator to the very first element.
Definition HashSet_inl.h:437
plHashSetBase(const plHashSetBase< KeyType, Hasher > &rhs, plAllocator *pAllocator)
Creates a copy of the given hashset.
void operator=(const plHashSetBase< KeyType, Hasher > &rhs)
Copies the data from another hashset into this one.
ConstIterator GetEndIterator() const
Returns a constant Iterator to the first element that is not part of the hashset. Needed to implement...
Definition HashSet_inl.h:445
bool Remove(const CompatibleKeyType &key)
Removes the entry with the given key. Returns if an entry was removed.
Definition HashSet_inl.h:310