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