Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
THashList.h
Go to the documentation of this file.
1 // @(#)root/cont:$Id$
2 // Author: Fons Rademakers 10/08/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_THashList
13 #define ROOT_THashList
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // THashList //
19 // //
20 // THashList implements a hybrid collection class consisting of a //
21 // hash table and a list to store TObject's. The hash table is used for //
22 // quick access and lookup of objects while the list allows the objects //
23 // to be ordered. The hash value is calculated using the value returned //
24 // by the TObject's Hash() function. Each class inheriting from TObject //
25 // can override Hash() as it sees fit. //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 #include "TList.h"
30 
31 class THashTable;
32 
33 
34 class THashList : public TList {
35 
36 protected:
37  THashTable *fTable; //Hashtable used for quick lookup of objects
38 
39 private:
40  THashList(const THashList&); // not implemented
41  THashList& operator=(const THashList&); // not implemented
42 
43 public:
44  THashList(Int_t capacity=TCollection::kInitHashTableCapacity, Int_t rehash=0);
45  THashList(TObject *parent, Int_t capacity=TCollection::kInitHashTableCapacity, Int_t rehash=0);
46  virtual ~THashList();
47  Float_t AverageCollisions() const;
48  void Clear(Option_t *option="");
49  void Delete(Option_t *option="");
50 
51  TObject *FindObject(const char *name) const;
52  TObject *FindObject(const TObject *obj) const;
53 
54  const TList *GetListForObject(const char *name) const;
55  const TList *GetListForObject(const TObject *obj) const;
56 
57  void AddFirst(TObject *obj);
58  void AddFirst(TObject *obj, Option_t *opt);
59  void AddLast(TObject *obj);
60  void AddLast(TObject *obj, Option_t *opt);
61  void AddAt(TObject *obj, Int_t idx);
62  void AddAfter(const TObject *after, TObject *obj);
63  void AddAfter(TObjLink *after, TObject *obj);
64  void AddBefore(const TObject *before, TObject *obj);
65  void AddBefore(TObjLink *before, TObject *obj);
66  void RecursiveRemove(TObject *obj);
67  void Rehash(Int_t newCapacity);
68  TObject *Remove(TObject *obj);
69  TObject *Remove(TObjLink *lnk);
70  bool UseRWLock();
71 
72  ClassDef(THashList,0) //Doubly linked list with hashtable for lookup
73 };
74 
75 #endif