ROOT » CORE » CONT » THashTable

class THashTable: public TCollection


THashTable implements a hash table to store TObject's. The hash
value is calculated using the value returned by the TObject's
Hash() function. Each class inheriting from TObject can override
Hash() as it sees fit.
THashTable does not preserve the insertion order of the objects.
If the insertion order is important AND fast retrieval is needed
use THashList instead.

/* */

Function Members (Methods)

voidTObject::AbstractMethod(const char* method) const
virtual voidAdd(TObject* obj)
virtual voidAddAll(const TCollection* col)
voidAddBefore(const TObject* before, TObject* obj)
voidTCollection::AddVector(TObject* obj1)
virtual voidTObject::AppendPad(Option_t* option = "")
Bool_tTCollection::AssertClass(TClass* cl) const
Float_tAverageCollisions() const
TIterTCollection::begin() const
virtual voidTCollection::Browse(TBrowser* b)
Int_tTCollection::Capacity() const
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidClear(Option_t* option = "")
virtual TObject*TCollection::Clone(const char* newname = "") const
Int_tCollisions(const char* name) const
Int_tCollisions(TObject* obj) const
virtual Int_tTCollection::Compare(const TObject* obj) const
Bool_tTCollection::Contains(const char* name) const
Bool_tTCollection::Contains(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
virtual voidDelete(Option_t* option = "")
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTCollection::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTCollection::Dump() const
static voidTCollection::EmptyGarbageCollection()
TIterTCollection::end() const
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*FindObject(const char* name) const
virtual TObject*FindObject(const TObject* obj) const
static voidTCollection::GarbageCollect(TObject* obj)
static TCollection*TCollection::GetCurrentCollection()
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual Int_tTCollection::GetEntries() const
virtual const char*TObject::GetIconName() const
TList*GetListForObject(const char* name) const
TList*GetListForObject(const TObject* obj) const
virtual const char*TCollection::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
virtual TObject**GetObjectRef(const TObject* obj) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
Int_tGetRehashLevel() const
virtual Int_tGetSize() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Int_tTCollection::GrowBy(Int_t delta) const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTCollection::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
Bool_tTCollection::IsArgNull(const char* where, const TObject* obj) const
virtual Bool_tTCollection::IsEmpty() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTCollection::IsFolder() const
Bool_tTObject::IsOnHeap() const
Bool_tTCollection::IsOwner() const
virtual Bool_tTCollection::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTCollection::ls(Option_t* option = "") const
virtual TIterator*MakeIterator(Bool_t dir = kIterForward) const
virtual TIterator*TCollection::MakeReverseIterator() const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
voidTObject::operator delete(void* ptr)
voidTObject::operator delete(void* ptr, void* vp)
voidTObject::operator delete[](void* ptr)
voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TObject*TCollection::operator()(const char* name) const
virtual voidTCollection::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTCollection::Print(Option_t* option = "") const
virtual voidTCollection::Print(Option_t* option, Int_t recurse) const
virtual voidTCollection::Print(Option_t* option, const char* wildcard, Int_t recurse = 1) const
virtual voidTCollection::Print(Option_t* option, TPRegexp& regexp, Int_t recurse = 1) const
virtual Int_tTObject::Read(const char* name)
virtual voidTCollection::RecursiveRemove(TObject* obj)
voidRehash(Int_t newCapacity, Bool_t checkObjValidity = kTRUE)
virtual TObject*Remove(TObject* obj)
virtual voidTCollection::RemoveAll(TCollection* col)
TObject*RemoveSlow(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidTCollection::SetName(const char* name)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTCollection::SetOwner(Bool_t enable = kTRUE)
voidSetRehashLevel(Int_t rehash)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp) const
static voidTCollection::StartGarbageCollection()
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
THashTable(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0)
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTCollection::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTCollection::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
virtual const char*TCollection::GetCollectionEntryName(TObject* entry) const
virtual voidTCollection::PrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const
virtual voidTCollection::PrintCollectionHeader(Option_t* option) const
Int_tGetHashValue(const TObject* obj) const
Int_tGetHashValue(TString& s) const
Int_tGetHashValue(const char* str) const
THashTable&operator=(const THashTable&)
THashTable(const THashTable&)

Data Members

static TObject::(anonymous)TObject::kBitMask
static TObject::EStatusBitsTObject::kCanDelete
static TObject::EStatusBitsTObject::kCannotPick
static TObject::EStatusBitsTObject::kHasUUID
static TCollection::(anonymous)TCollection::kInitCapacity
static TCollection::(anonymous)TCollection::kInitHashTableCapacity
static TObject::EStatusBitsTObject::kInvalidObject
static TObject::(anonymous)TObject::kIsOnHeap
static TObject::EStatusBitsTObject::kIsReferenced
static TObject::EStatusBitsTObject::kMustCleanup
static TObject::EStatusBitsTObject::kNoContextMenu
static TObject::(anonymous)TObject::kNotDeleted
static TObject::EStatusBitsTObject::kObjInCanvas
static TObject::(anonymous)TObject::kOverwrite
static TObject::(anonymous)TObject::kSingleKey
static TObject::(anonymous)TObject::kWriteDelete
static TObject::(anonymous)TObject::kZombie
TStringTCollection::fNamename of the collection
Int_tTCollection::fSizenumber of elements in collection
static TCollection::(anonymous)TCollection::kIsOwner
TList**fContHash table (table of lists)
Int_tfEntriesNumber of objects in table
Int_tfRehashLevelAverage collision rate which triggers rehash
Int_tfUsedSlotsNumber of used slots

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

THashTable(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0)
 Create a THashTable object. Capacity is the initial hashtable capacity
 (i.e. number of slots), by default kInitHashTableCapacity = 17, and
 rehashlevel is the value at which a rehash will be triggered. I.e. when
 the average size of the linked lists at a slot becomes longer than
 rehashlevel then the hashtable will be resized and refilled to reduce
 the collision rate to about 1. The higher the collision rate, i.e. the
 longer the linked lists, the longer lookup will take. If rehashlevel=0
 the table will NOT automatically be rehashed. Use Rehash() for manual
 Delete a hashtable. Objects are not deleted unless the THashTable is the
 owner (set via SetOwner()).
void Add(TObject* obj)
 Add object to the hash table. Its position in the table will be
 determined by the value returned by its Hash() function.
void AddBefore(const TObject* before, TObject* obj)
 Add object to the hash table. Its position in the table will be
 determined by the value returned by its Hash() function.
 If and only if 'before' is in the same bucket as obj, obj is added
 in front of 'before' within the bucket's list.
void AddAll(const TCollection* col)
 Add all objects from collection col to this collection.
 Implemented for more efficient rehashing.
void Clear(Option_t* option = "")
 Remove all objects from the table. Does not delete the objects
 unless the THashTable is the owner (set via SetOwner()).
Int_t Collisions(const char* name) const
 Returns the number of collisions for an object with a certain name
 (i.e. number of objects in same slot in the hash table, i.e. length
 of linked list).
Int_t Collisions(TObject* obj) const
 Returns the number of collisions for an object (i.e. number of objects
 in same slot in the hash table, i.e. length of linked list).
void Delete(Option_t* option = "")
 Remove all objects from the table AND delete all heap based objects.
TObject * FindObject(const char* name) const
 Find object using its name. Uses the hash value returned by the
 TString::Hash() after converting name to a TString.
TObject * FindObject(const TObject* obj) const
 Find object using its hash value (returned by its Hash() member).
TList * GetListForObject(const char* name) const
 Return the TList corresponding to object's name based hash value.
 One can iterate this list "manually" to find, e.g. objects with
 the same name.
TList * GetListForObject(const TObject* obj) const
 Return the TList corresponding to object's hash value.
 One can iterate this list "manually" to find, e.g. identical
TObject ** GetObjectRef(const TObject* obj) const
 Return address of pointer to obj
TIterator * MakeIterator(Bool_t dir = kIterForward) const
 Returns a hash table iterator.
void Rehash(Int_t newCapacity, Bool_t checkObjValidity = kTRUE)
 Rehash the hashtable. If the collision rate becomes too high (i.e.
 the average size of the linked lists become too long) then lookup
 efficiency decreases since relatively long lists have to be searched
 every time. To improve performance rehash the hashtable. This resizes
 the table to newCapacity slots and refills the table. Use
 AverageCollisions() to check if you need to rehash. Set checkObjValidity
 to kFALSE if you know that all objects in the table are still valid
 (i.e. have not been deleted from the system in the meanwhile).
TObject * Remove(TObject* obj)
 Remove object from the hashtable.
TObject * RemoveSlow(TObject* obj)
 Remove object from the hashtable without using the hash value.
Float_t AverageCollisions() const
Int_t GetHashValue(const TObject* obj) const
Int_t GetHashValue(const TObject* obj) const
Int_t GetHashValue(TString& s) const
{ return s.Hash() % fSize; }
THashTable(const THashTable& )
THashTable& operator=(const THashTable& )
Int_t GetRehashLevel() const
{ return fRehashLevel; }
Int_t GetSize() const
{ return fEntries; }
void SetRehashLevel(Int_t rehash)
{ fRehashLevel = rehash; }