#ifndef ROOT_THashTable
#define ROOT_THashTable
#ifndef ROOT_TCollection
#include "TCollection.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
class TList;
class TListIter;
class THashTableIter;
class THashTable : public TCollection {
friend class THashTableIter;
private:
TList **fCont;
Int_t fEntries;
Int_t fUsedSlots;
Int_t fRehashLevel;
Int_t GetHashValue(const TObject *obj) const;
Int_t GetHashValue(TString &s) const { return s.Hash() % fSize; }
Int_t GetHashValue(const char *str) const { return ::Hash(str) % fSize; }
THashTable(const THashTable&);
THashTable& operator=(const THashTable&);
public:
THashTable(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0);
virtual ~THashTable();
void Add(TObject *obj);
virtual void AddAll(const TCollection *col);
Float_t AverageCollisions() const;
void Clear(Option_t *option="");
Int_t Collisions(const char *name) const;
Int_t Collisions(TObject *obj) const;
void Delete(Option_t *option="");
TObject *FindObject(const char *name) const;
TObject *FindObject(const TObject *obj) const;
TList *GetListForObject(const char *name) const;
TList *GetListForObject(const TObject *obj) const;
TObject **GetObjectRef(const TObject *obj) const;
Int_t GetRehashLevel() const { return fRehashLevel; }
Int_t GetSize() const { return fEntries; }
TIterator *MakeIterator(Bool_t dir = kIterForward) const;
void Rehash(Int_t newCapacity, Bool_t checkObjValidity = kTRUE);
TObject *Remove(TObject *obj);
TObject *RemoveSlow(TObject *obj);
void SetRehashLevel(Int_t rehash) { fRehashLevel = rehash; }
ClassDef(THashTable,0)
};
inline Float_t THashTable::AverageCollisions() const
{
if (fUsedSlots)
return ((Float_t)fEntries)/fUsedSlots;
else
return 0.0;
}
inline Int_t THashTable::GetHashValue(const TObject *obj) const
{
Int_t i = Int_t(obj->Hash() % fSize);
return i;
}
class THashTableIter : public TIterator {
private:
const THashTable *fTable;
Int_t fCursor;
TListIter *fListCursor;
Bool_t fDirection;
THashTableIter() : fTable(0), fCursor(0), fListCursor(0), fDirection(kIterForward) { }
Int_t NextSlot();
public:
THashTableIter(const THashTable *ht, Bool_t dir = kIterForward);
THashTableIter(const THashTableIter &iter);
~THashTableIter();
TIterator &operator=(const TIterator &rhs);
THashTableIter &operator=(const THashTableIter &rhs);
const TCollection *GetCollection() const { return fTable; }
TObject *Next();
void Reset();
bool operator!=(const TIterator &aIter) const;
bool operator!=(const THashTableIter &aIter) const;
TObject *operator*() const;
ClassDef(THashTableIter,0)
};
#endif
Last change: Wed Jun 25 08:47:10 2008
Last generated: 2008-06-25 08:47
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.