Logo ROOT   6.21/01
Reference Guide
RooLinkedList.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooLinkedList.h,v 1.15 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_LINKED_LIST
17 #define ROO_LINKED_LIST
18 
19 #include <map>
20 #include <list>
21 #include <vector>
22 
23 #include "TNamed.h"
24 #include "RooLinkedListElem.h"
25 #include "RooHashTable.h"
26 class RooLinkedListIter ;
27 class RooFIter;
28 class TIterator ;
29 class RooAbsArg ;
30 
32  class Chunk;
33  class Pool;
34 }
35 
36 class RooLinkedList : public TObject {
37 public:
38  // Constructor
39  RooLinkedList(Int_t htsize=0) ;
40 
41  // Copy constructor
42  RooLinkedList(const RooLinkedList& other) ;
43 
44  virtual TObject* Clone(const char* =0) const {
45  return new RooLinkedList(*this) ;
46  }
47 
48  // Assignment operator
49  RooLinkedList& operator=(const RooLinkedList& other) ;
50 
52  // Return size of hash table
53  return _htableName ? _htableName->size() : 0 ;
54  }
55 
56  void setHashTableSize(Int_t size) ;
57 
58  // Destructor
59  virtual ~RooLinkedList() ;
60 
61  Int_t GetSize() const { return _size ; }
62 
63  virtual void Add(TObject* arg) { Add(arg,1) ; }
64  virtual Bool_t Remove(TObject* arg) ;
65  TObject* At(Int_t index) const ;
66  Bool_t Replace(const TObject* oldArg, const TObject* newArg) ;
69  RooFIter fwdIterator() const ;
70 
71  void Clear(Option_t *o=0) ;
72  void Delete(Option_t *o=0) ;
73  TObject* find(const char* name) const ;
74  RooAbsArg* findArg(const RooAbsArg*) const ;
75  TObject* FindObject(const char* name) const ;
76  TObject* FindObject(const TObject* obj) const ;
77  Int_t IndexOf(const char* name) const ;
78  Int_t IndexOf(const TObject* arg) const ;
79  TObject* First() const {
80  return _first?_first->_arg:0 ;
81  }
82 
83  virtual void RecursiveRemove(TObject *obj);
84 
85  void Print(const char* opt) const ;
86  void Sort(Bool_t ascend=kTRUE) ;
87 
88  // const char* GetName() const { return "" ; /*_name.Data() ; */ }
89  // void SetName(const char* /*name*/) { /*_name = name ; */ }
90  const char* GetName() const { return _name.Data() ; }
91  void SetName(const char* name) { _name = name ; }
92 
93  void useNptr(Bool_t flag) { _useNptr = flag ; }
94  // needed for using it in THashList/THashTable
95 
96  ULong_t Hash() const { return _name.Hash(); }
97  //ULong_t Hash() const { return TString().Hash(); }
98 
99 protected:
100 
103 
104 
105  friend class RooLinkedListIterImpl ;
106  friend class RooFIterForLinkedList ;
107 
108  virtual void Add(TObject* arg, Int_t refCount) ;
109 
110  RooLinkedListElem* findLink(const TObject* arg) const ;
111 
112  Int_t _hashThresh ; // Size threshold for hashing
113  Int_t _size ; // Current size of list
114  RooLinkedListElem* _first ; //! Link to first element of list
115  RooLinkedListElem* _last ; //! Link to last element of list
116  RooHashTable* _htableName ; //! Hash table by name
117  RooHashTable* _htableLink ; //! Hash table by link pointer
118 
121 
122 private:
123  template <bool ascending>
125  const unsigned sz, RooLinkedListElem** tail = 0);
126  /// memory pool for quick allocation of RooLinkedListElems
127  typedef RooLinkedListImplDetails::Pool Pool;
128  /// shared memory pool for allocation of RooLinkedListElems
129  static Pool* _pool; //!
130 
131  std::vector<RooLinkedListElem *> _at; //! index list for quick index through ::At
132 
133  ClassDef(RooLinkedList,3) // Doubly linked list for storage of RooAbsArg objects
134 };
135 
136 
137 
138 
139 #endif
Int_t IndexOf(const char *name) const
Return position of given object in list.
static RooLinkedListElem * mergesort_impl(RooLinkedListElem *l1, const unsigned sz, RooLinkedListElem **tail=0)
length 0, 1 lists are sorted
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
const char * GetName() const
Returns name of object.
Definition: RooLinkedList.h:90
RooHashTable * _htableLink
Hash table by name.
ULong_t Hash() const
Return hash value for this object.
Definition: RooLinkedList.h:96
virtual Bool_t Remove(TObject *arg)
Remove object from collection.
void setHashTableSize(Int_t size)
Change the threshold for hash-table use to given size.
const char Option_t
Definition: RtypesCore.h:62
TObject * find(const char *name) const
Return pointer to object with given name in collection.
Basic string class.
Definition: TString.h:131
virtual TObject * Clone(const char *=0) const
Make a clone of an object using the Streamer facility.
Definition: RooLinkedList.h:44
RooFIter fwdIterator() const
Create a one-time-use forward iterator for this list.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t getHashTableSize() const
Definition: RooLinkedList.h:51
RooLinkedListImplDetails::Pool Pool
memory pool for quick allocation of RooLinkedListElems
void Clear(Option_t *o=0)
Remove all elements from collection.
void SetName(const char *name)
Definition: RooLinkedList.h:91
TObject * First() const
Definition: RooLinkedList.h:79
Int_t GetSize() const
Definition: RooLinkedList.h:61
Iterator abstract base class.
Definition: TIterator.h:30
void Sort(Bool_t ascend=kTRUE)
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition: TString.cxx:638
Bool_t Replace(const TObject *oldArg, const TObject *newArg)
Replace object &#39;oldArg&#39; in collection with new object &#39;newArg&#39;.
RooLinkedListIter iterator(Bool_t forward=kTRUE) const
Create an iterator for this list.
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
#define ClassDef(name, id)
Definition: Rtypes.h:326
std::vector< RooLinkedListElem * > _at
RooLinkedListElem * _first
TString _name
Hash table by link pointer.
RooHashTable implements a hash table for TObjects.
Definition: RooHashTable.h:28
RooLinkedListElem * findLink(const TObject *arg) const
Find the element link containing the given object.
void useNptr(Bool_t flag)
Definition: RooLinkedList.h:93
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:63
Implementation of the GenericRooFIter interface for the RooLinkedList.
RooLinkedList(Int_t htsize=0)
TObject * At(Int_t index) const
Return object stored in sequential position given by index.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:36
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements...
unsigned long ULong_t
Definition: RtypesCore.h:51
Int_t size() const
Definition: RooHashTable.h:48
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN
Definition: NeuralNet.icc:546
TIterator * MakeIterator(Bool_t forward=kTRUE) const
Create a TIterator for this list.
RooLinkedList & operator=(const RooLinkedList &other)
Assignment operator, copy contents from &#39;other&#39;.
Mother of all ROOT objects.
Definition: TObject.h:37
Implementation of the actual iterator on RooLinkedLists.
RooLinkedListElem * _last
Link to first element of list.
void deleteElement(RooLinkedListElem *)
static Pool * _pool
shared memory pool for allocation of RooLinkedListElems
void Print(const char *opt) const
Print contents of list, defers to Print() function of contained objects.
virtual ~RooLinkedList()
Destructor.
RooAbsArg * findArg(const RooAbsArg *) const
Return pointer to object with given name in collection.
RooLinkedListElem is an link element for the RooLinkedList class.
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:71
RooLinkedListElem * createElement(TObject *obj, RooLinkedListElem *elem=0)
cout << "RooLinkedList::createElem(" << this << ") obj = " << obj << " elem = " << elem << endl ; ...
const Bool_t kTRUE
Definition: RtypesCore.h:87
A wrapper around TIterator derivatives.
char name[80]
Definition: TGX11.cxx:109
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooHashTable * _htableName
Link to last element of list.
const char * Data() const
Definition: TString.h:364