00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef ROO_HASH_TABLE
00017 #define ROO_HASH_TABLE
00018
00019 #include "TObject.h"
00020 #include "TString.h"
00021
00022 class RooAbsArg ;
00023 class RooLinkedList ;
00024 class RooLinkedListElem ;
00025 class RooSetPair ;
00026 class RooArgSet ;
00027
00028 class RooHashTable : public TObject {
00029 public:
00030
00031 enum HashMethod { Pointer=0, Name=1, Intrinsic=2 } ;
00032
00033
00034 RooHashTable(Int_t initSize = 17, HashMethod hashMethod=Name) ;
00035 RooHashTable(const RooHashTable& other) ;
00036
00037
00038 virtual ~RooHashTable() ;
00039
00040 void add(TObject* arg, TObject* hashArg=0) ;
00041 Bool_t remove(TObject* arg, TObject* hashArg=0) ;
00042 TObject* find(const char* name) const ;
00043 TObject* find(const TObject* arg) const ;
00044 RooLinkedListElem* findLinkTo(const TObject* arg) const ;
00045 RooSetPair* findSetPair(const RooArgSet* set1, const RooArgSet* set2) const ;
00046 Bool_t replace(const TObject* oldArg, const TObject* newArg, const TObject* oldHashArg=0) ;
00047 Int_t size() const { return _size ; }
00048 Double_t avgCollisions() const ;
00049
00050 protected:
00051 inline ULong_t hash(const TObject* arg) const {
00052
00053 switch(_hashMethod) {
00054 case Pointer: return TString::Hash((void*)(&arg),sizeof(void*)) ;
00055 case Name: return TString::Hash(arg->GetName(),strlen(arg->GetName())) ;
00056 case Intrinsic: return arg->Hash() ;
00057 }
00058 return 0 ;
00059 }
00060
00061 HashMethod _hashMethod ;
00062 Int_t _usedSlots ;
00063 Int_t _entries ;
00064 Int_t _size ;
00065 RooLinkedList** _arr ;
00066
00067 ClassDef(RooHashTable,1)
00068 };
00069
00070
00071
00072
00073 #endif