5 #include <libutl/BitArray.h> 6 #include <libutl/Collection.h> 7 #include <libutl/PointerIntPair.h> 8 #include <libutl/Vector.h> 9 #include <libutl/dlist.h> 45 return object->hash(size);
48 size_t operator()(
const Object*
object,
size_t size)
const 50 return hash(
object, size);
112 bool multiSet =
false,
115 init(size, maxLF, owner, multiSet, hfunc);
126 init(0, 90, owner, multiSet, hfunc);
129 virtual void steal(
Object& rhs);
131 virtual void vclone(
const Object& rhs);
133 virtual size_t innerAllocatedSize()
const;
146 void reserve(
size_t newSize);
153 iterator findIt(
const Object& key)
const;
155 iterator findIt(
const Object& key);
172 return super::add(
object);
175 virtual bool add(
const Object*
object);
180 super::add(collection);
184 addOrFind(
const Object&
object)
186 return super::addOrFind(
object);
192 addOrUpdate(
const Object&
object)
194 return super::addOrUpdate(
object);
197 virtual bool addOrUpdate(
const Object*
object);
202 virtual void clear();
217 virtual bool remove(
const Object& key);
219 virtual void removeIt(
BidIt& it);
224 iterator begin()
const;
228 virtual BidIt* beginNew()
const;
230 virtual BidIt* beginNew();
232 inline iterator end()
const;
234 inline iterator end();
236 virtual BidIt* endNew()
const;
238 virtual BidIt* endNew();
242 void init(
size_t size = 0,
245 bool multiSet =
false,
249 void grow(
size_t newSize);
253 void remove(
size_t idx,
ListNode* node);
256 hash(
const Object*
object)
const 259 if (_hashfn ==
nullptr)
return object->hash(_array.size());
260 return _hashfn->hash(
object, _array.size());
264 isObject(
size_t idx)
const 266 return (_array[idx].getInt() == 0);
269 auto getObject(
size_t idx)
const 272 return _array[idx].getPointer();
275 auto setObject(
size_t idx,
Object* obj)
277 _array[idx].set(obj, 0);
282 isHead(
size_t idx)
const 284 return (_array[idx].getInt() == 1);
288 getHead(
size_t idx)
const 291 return reinterpret_cast<ListNode*
>(_array[idx].getPointer());
297 _array[idx].
set(reinterpret_cast<Object*>(ln), 1);
308 static size_t primes[];
317 #include <libutl/THashtable.h>
virtual size_t hash(const Object *object, size_t size) const
Compute the hash function for the given object.
T * clone(const T *object)
Create a clone of the given object.
#define const_cast_this
Pointer to the object the method was invoked on (casting away const).
void setHashFunction(const HashFunction *hashfn)
Set the hash function.
void deInit()
De-initialize UTL++.
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Templated proxy for BidIt.
#define IFDEBUG(x)
Do x in DEBUG mode only.
virtual ~HashFunction()
Virtual destructor.
Hashtable(size_t size, uint_t maxLF=90, bool owner=true, bool multiSet=false, const HashFunction *hfunc=nullptr)
Constructor.
void setConst(bool p_const)
Set the const flag.
unsigned int uint_t
Unsigned integer.
Bi-directional Hashtable iterator.
void set(const Object *object)
Set the contained object.
Hashtable(bool owner, bool multiSet=false, const HashFunction *hfunc=nullptr)
Constructor.
Bi-directional iterator abstraction.
Chained hashing collection.
A sequence of same-type objects.
Root of UTL++ class hierarchy.
void init()
Initialize UTL++.
#define ASSERTD
Do an assertion in DEBUG mode only.