Logo ROOT  
Reference Guide
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
31class THashTable;
32
33
34class THashList : public TList {
35
36protected:
37 THashTable *fTable; //Hashtable used for quick lookup of objects
38
39private:
40 THashList(const THashList&) = delete;
41 THashList& operator=(const THashList&) = delete;
42
43public:
46 virtual ~THashList();
48 void Clear(Option_t *option="") override;
49 void Delete(Option_t *option="") override;
50
51 TObject *FindObject(const char *name) const override;
52 TObject *FindObject(const TObject *obj) const override;
53
54 const TList *GetListForObject(const char *name) const;
55 const TList *GetListForObject(const TObject *obj) const;
56
57 void AddFirst(TObject *obj) override;
58 void AddFirst(TObject *obj, Option_t *opt) override;
59 void AddLast(TObject *obj) override;
60 void AddLast(TObject *obj, Option_t *opt) override;
61 void AddAt(TObject *obj, Int_t idx) override;
62 void AddAfter(const TObject *after, TObject *obj) override;
63 void AddAfter(TObjLink *after, TObject *obj) override;
64 void AddBefore(const TObject *before, TObject *obj) override;
65 void AddBefore(TObjLink *before, TObject *obj) override;
66 void RecursiveRemove(TObject *obj) override;
67 void Rehash(Int_t newCapacity);
68 TObject *Remove(TObject *obj) override;
69 TObject *Remove(TObjLink *lnk) override;
70 bool UseRWLock(Bool_t enable = true) override;
71
72 ClassDefOverride(THashList,0) //Doubly linked list with hashtable for lookup
73};
74
75#endif
float Float_t
Definition: RtypesCore.h:57
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
Option_t Option_t option
char name[80]
Definition: TGX11.cxx:110
@ kInitHashTableCapacity
Definition: TCollection.h:159
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition: THashList.cxx:207
void AddBefore(const TObject *before, TObject *obj) override
Insert object before object before in the list.
Definition: THashList.cxx:121
THashList & operator=(const THashList &)=delete
void Clear(Option_t *option="") override
Remove all objects from the list.
Definition: THashList.cxx:189
void AddFirst(TObject *obj) override
Add object at the beginning of the list.
Definition: THashList.cxx:69
void Rehash(Int_t newCapacity)
Rehash the hashlist.
Definition: THashList.cxx:368
virtual ~THashList()
Delete a hashlist.
Definition: THashList.cxx:60
void AddAfter(const TObject *after, TObject *obj) override
Insert object after object after in the list.
Definition: THashList.cxx:143
THashTable * fTable
Definition: THashList.h:37
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition: THashList.cxx:310
void AddAt(TObject *obj, Int_t idx) override
Insert object at location idx in the list.
Definition: THashList.cxx:165
THashList(const THashList &)=delete
const TList * GetListForObject(const char *name) const
Return the THashTable's list (bucket) in which obj can be found based on its hash; see THashTable::Ge...
Definition: THashList.cxx:283
bool UseRWLock(Bool_t enable=true) override
Set this collection to use a RW lock upon access, making it thread safe.
Definition: THashList.cxx:409
Float_t AverageCollisions() const
Return the average collision rate.
Definition: THashList.cxx:178
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition: THashList.cxx:378
TObject * FindObject(const char *name) const override
Find object using its name.
Definition: THashList.cxx:262
void AddLast(TObject *obj) override
Add object at the end of the list.
Definition: THashList.cxx:95
THashTable implements a hash table to store TObject's.
Definition: THashTable.h:35
A doubly linked list.
Definition: TList.h:38
Mother of all ROOT objects.
Definition: TObject.h:37