Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooHashTable.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooHashTable.h,v 1.12 2007/05/11 09:11:30 verkerke Exp $
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef ROO_HASH_TABLE
17#define ROO_HASH_TABLE
18
19#include "TObject.h"
20#include "TString.h"
21
22class RooAbsArg ;
23class RooLinkedList ;
25class RooSetPair ;
26class RooArgSet ;
27
28class RooHashTable : public TObject {
29public:
30
31 enum HashMethod { Pointer=0, Name=1, Intrinsic=2 } ;
32
33 // Constructor
34 RooHashTable(Int_t initSize = 17, HashMethod hashMethod=Name) ;
35 RooHashTable(const RooHashTable& other) ;
36
37 // Destructor
38 virtual ~RooHashTable() ;
39
40 void add(TObject* arg, TObject* hashArg=0) ;
41 Bool_t remove(TObject* arg, TObject* hashArg=0) ;
42 TObject* find(const char* name) const ;
43 RooAbsArg* findArg(const RooAbsArg* arg) const ;
44 TObject* find(const TObject* arg) const ;
45 RooLinkedListElem* findLinkTo(const TObject* arg) const ;
46 RooSetPair* findSetPair(const RooArgSet* set1, const RooArgSet* set2) const ;
47 Bool_t replace(const TObject* oldArg, const TObject* newArg, const TObject* oldHashArg=0) ;
48 Int_t size() const { return _size ; }
49 Int_t entries() const { return _entries ; }
50 Double_t avgCollisions() const ;
51
52protected:
53 inline ULong_t hash(const TObject* arg) const {
54 // Return hash value calculated by method chosen in constructor
55 switch(_hashMethod) {
56 case Pointer: return TString::Hash((void*)(&arg),sizeof(void*)) ;
57 case Name: return TString::Hash(arg->GetName(),strlen(arg->GetName())) ;
58 case Intrinsic: return arg->Hash() ;
59 }
60 return 0 ;
61 }
62
63 HashMethod _hashMethod ; // Hashing method
64 Int_t _usedSlots ; // Number of used slots
65 Int_t _entries ; // Number of entries stored
66 Int_t _size ; // Total number of slots
67 RooLinkedList** _arr ; //! Array of linked lists storing elements in each slot
68
69 ClassDef(RooHashTable,1) // Hash table
70};
71
72
73
74
75#endif
int Int_t
Definition RtypesCore.h:45
unsigned long ULong_t
Definition RtypesCore.h:55
bool Bool_t
Definition RtypesCore.h:63
double Double_t
Definition RtypesCore.h:59
#define ClassDef(name, id)
Definition Rtypes.h:325
char name[80]
Definition TGX11.cxx:110
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition RooAbsArg.h:72
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:29
RooHashTable implements a hash table for TObjects.
RooLinkedList ** _arr
Bool_t remove(TObject *arg, TObject *hashArg=0)
Remove given object from table.
Int_t size() const
RooLinkedListElem * findLinkTo(const TObject *arg) const
Return RooLinkedList element link to object 'hashArg'.
Int_t entries() const
HashMethod _hashMethod
Bool_t replace(const TObject *oldArg, const TObject *newArg, const TObject *oldHashArg=0)
Replace oldArg with newArg in the table.
ULong_t hash(const TObject *arg) const
RooSetPair * findSetPair(const RooArgSet *set1, const RooArgSet *set2) const
Return RooSetPair with given pointers in table.
TObject * find(const char *name) const
Return the object with given name from the table.
virtual ~RooHashTable()
Destructor.
Double_t avgCollisions() const
Calculate the average number of collisions (table slots with >1 filled entry)
void add(TObject *arg, TObject *hashArg=0)
Add given object to table.
RooAbsArg * findArg(const RooAbsArg *arg) const
RooLinkedListElem is an link element for the RooLinkedList class.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
RooSetPair is a utility class that stores a pair of RooArgSets.
Definition RooSetPair.h:26
Mother of all ROOT objects.
Definition TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:359
virtual ULong_t Hash() const
Return hash value for this object.
Definition TObject.cxx:435
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition TString.cxx:658