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 "TObject.h"
20 #include "RooLinkedListElem.h"
21 #include "TString.h"
22 
23 #include <vector>
24 #include <memory>
25 #include <unordered_map>
26 
27 class RooLinkedListIter ;
28 class RooFIter;
29 class TIterator ;
30 class RooAbsArg ;
31 
33  class Chunk;
34  class Pool;
35 }
36 
37 class RooLinkedList : public TObject {
38 public:
39  // Constructor
40  RooLinkedList(Int_t htsize=0) ;
41 
42  // Copy constructor
43  RooLinkedList(const RooLinkedList& other) ;
44 
45  virtual TObject* Clone(const char* =0) const {
46  return new RooLinkedList(*this) ;
47  }
48 
49  // Assignment operator
50  RooLinkedList& operator=(const RooLinkedList& other) ;
51 
53  // Return size of hash table
54  return _htableName ? _htableName->size() : 0 ;
55  }
56 
58 
59  // Destructor
60  virtual ~RooLinkedList() ;
61 
62  Int_t GetSize() const { return _size ; }
63 
64  virtual void Add(TObject* arg) { Add(arg,1) ; }
65  virtual Bool_t Remove(TObject* arg) ;
66  TObject* At(int index) const ;
67  Bool_t Replace(const TObject* oldArg, const TObject* newArg) ;
70  RooFIter fwdIterator() const ;
71 
72  void Clear(Option_t *o=0) ;
73  void Delete(Option_t *o=0) ;
74  TObject* find(const char* name) const ;
75  RooAbsArg* findArg(const RooAbsArg*) const ;
76  TObject* FindObject(const char* name) const ;
77  TObject* FindObject(const TObject* obj) const ;
78  Int_t IndexOf(const char* name) const ;
79  Int_t IndexOf(const TObject* arg) const ;
80  TObject* First() const {
81  return _first?_first->_arg:0 ;
82  }
83 
84  virtual void RecursiveRemove(TObject *obj);
85 
86  void Print(const char* opt) const ;
87  void Sort(Bool_t ascend=kTRUE) ;
88 
89  // const char* GetName() const { return "" ; /*_name.Data() ; */ }
90  // void SetName(const char* /*name*/) { /*_name = name ; */ }
91  const char* GetName() const { return _name.Data() ; }
92  void SetName(const char* name) { _name = name ; }
93 
94  void useNptr(Bool_t flag) { _useNptr = flag ; }
95  // needed for using it in THashList/THashTable
96 
97  ULong_t Hash() const { return _name.Hash(); }
98  //ULong_t Hash() const { return TString().Hash(); }
99 
100 protected:
101 
104 
105 
106  friend class RooLinkedListIterImpl ;
107  friend class RooFIterForLinkedList ;
108 
109  virtual void Add(TObject* arg, Int_t refCount) ;
110 
111  RooLinkedListElem* findLink(const TObject* arg) const ;
112 
113  Int_t _hashThresh ; // Size threshold for hashing
114  Int_t _size ; // Current size of list
115  RooLinkedListElem* _first ; //! Link to first element of list
116  RooLinkedListElem* _last ; //! Link to last element of list
117 
118  using HashTableByName = std::unordered_map<std::string,TObject const*>;
119  using HashTableByLink = std::unordered_map<TObject const*,TObject const*>;
120  std::unique_ptr<HashTableByName> _htableName; //! Hash table by name
121  std::unique_ptr<HashTableByLink> _htableLink; //! Hash table by link pointer
122 
125 
126 private:
127  template <bool ascending>
129  const unsigned sz, RooLinkedListElem** tail = 0);
130  /// memory pool for quick allocation of RooLinkedListElems
132  /// shared memory pool for allocation of RooLinkedListElems
133  static Pool* _pool; //!
134 
135  std::vector<RooLinkedListElem *> _at; //! index list for quick index through ::At
136 
137  ClassDef(RooLinkedList,3) // Doubly linked list for storage of RooAbsArg objects
138 };
139 
140 #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:478
RooLinkedList::find
TObject * find(const char *name) const
Return pointer to object with given name in collection.
Definition: RooLinkedList.cxx:603
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:731
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
RooLinkedList::HashTableByName
std::unordered_map< std::string, TObject const * > HashTableByName
Link to last element of list.
Definition: RooLinkedList.h:118
RooLinkedList::_last
RooLinkedListElem * _last
Link to first element of list.
Definition: RooLinkedList.h:116
Option_t
const char Option_t
Definition: RtypesCore.h:66
RooLinkedList::~RooLinkedList
virtual ~RooLinkedList()
Destructor.
Definition: RooLinkedList.cxx:362
RooLinkedListImplDetails::Pool
Definition: RooLinkedList.cxx:114
RooLinkedList::HashTableByLink
std::unordered_map< TObject const *, TObject const * > HashTableByLink
Definition: RooLinkedList.h:119
TString::Data
const char * Data() const
Definition: TString.h:369
RooLinkedList::GetSize
Int_t GetSize() const
Definition: RooLinkedList.h:62
RooLinkedList::GetName
const char * GetName() const
Returns name of object.
Definition: RooLinkedList.h:91
Int_t
int Int_t
Definition: RtypesCore.h:45
TString::Hash
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition: TString.cxx:662
RooLinkedList::fwdIterator
RooFIter fwdIterator() const
Create a one-time-use forward iterator for this list.
Definition: RooLinkedList.cxx:750
RooLinkedList::Clone
virtual TObject * Clone(const char *=0) const
Make a clone of an object using the Streamer facility.
Definition: RooLinkedList.h:45
RooLinkedListImplDetails
Definition: RooLinkedList.h:32
RooLinkedList::getHashTableSize
Int_t getHashTableSize() const
Definition: RooLinkedList.h:52
TString
Basic string class.
Definition: TString.h:136
RooLinkedList::FindObject
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
Definition: RooLinkedList.cxx:531
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TString.h
RooLinkedList::Pool
RooLinkedListImplDetails::Pool Pool
memory pool for quick allocation of RooLinkedListElems
Definition: RooLinkedList.h:131
RooLinkedList::Hash
ULong_t Hash() const
Return hash value for this object.
Definition: RooLinkedList.h:97
bool
TIterator
Iterator abstract base class.
Definition: TIterator.h:30
RooLinkedList::SetName
void SetName(const char *name)
Definition: RooLinkedList.h:92
RooLinkedList::Replace
Bool_t Replace(const TObject *oldArg, const TObject *newArg)
Replace object 'oldArg' in collection with new object 'newArg'.
Definition: RooLinkedList.cxx:507
RooLinkedList::useNptr
void useNptr(Bool_t flag)
Definition: RooLinkedList.h:94
RooLinkedList::findArg
RooAbsArg * findArg(const RooAbsArg *) const
Return pointer to object with given name in collection.
Definition: RooLinkedList.cxx:659
RooLinkedListElem
RooLinkedListElem is an link element for the RooLinkedList class.
Definition: RooLinkedListElem.h:30
RooLinkedList::At
TObject * At(int index) const
Return object stored in sequential position given by index.
Definition: RooLinkedList.cxx:487
RooLinkedList::_first
RooLinkedListElem * _first
Definition: RooLinkedList.h:115
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:60
RooLinkedList::RooLinkedList
RooLinkedList(Int_t htsize=0)
Definition: RooLinkedList.cxx:263
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
RooLinkedList::mergesort_impl
static RooLinkedListElem * mergesort_impl(RooLinkedListElem *l1, const unsigned sz, RooLinkedListElem **tail=0)
length 0, 1 lists are sorted
Definition: RooLinkedList.cxx:773
RooFIter
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
Definition: RooLinkedListIter.h:40
RooLinkedListElem.h
RooLinkedList
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:37
RooLinkedList::Sort
void Sort(Bool_t ascend=kTRUE)
Definition: RooLinkedList.cxx:757
RooLinkedList::_htableName
std::unique_ptr< HashTableByName > _htableName
Definition: RooLinkedList.h:120
RooLinkedList::Add
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:64
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:741
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:135
RooLinkedListIterImpl
Implementation of the actual iterator on RooLinkedLists.
Definition: RooLinkedListIter.h:242
RooLinkedList::_useNptr
Bool_t _useNptr
Definition: RooLinkedList.h:124
RooLinkedList::_size
Int_t _size
Definition: RooLinkedList.h:114
RooLinkedList::_hashThresh
Int_t _hashThresh
Definition: RooLinkedList.h:113
RooLinkedList::_pool
static Pool * _pool
shared memory pool for allocation of RooLinkedListElems
Definition: RooLinkedList.h:133
RooLinkedList::First
TObject * First() const
Definition: RooLinkedList.h:80
RooLinkedList::deleteElement
void deleteElement(RooLinkedListElem *)
Definition: RooLinkedList.cxx:299
TObject.h
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
Mother of all ROOT objects.
Definition: TObject.h:37
RooLinkedList::Clear
void Clear(Option_t *o=0)
Remove all elements from collection.
Definition: RooLinkedList.cxx:549
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
RooLinkedList::_htableLink
std::unique_ptr< HashTableByLink > _htableLink
Hash table by name.
Definition: RooLinkedList.h:121
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooLinkedListImplDetails::Chunk
a chunk of memory in a pool for quick allocation of RooLinkedListElems
Definition: RooLinkedList.cxx:52
RooLinkedList::_name
TString _name
Hash table by link pointer.
Definition: RooLinkedList.h:123
RooLinkedList::IndexOf
Int_t IndexOf(const char *name) const
Return position of given object in list.
Definition: RooLinkedList.cxx:700
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:575
RooLinkedList::findLink
RooLinkedListElem * findLink(const TObject *arg) const
Find the element link containing the given object.
Definition: RooLinkedList.cxx:380
RooLinkedList::Print
void Print(const char *opt) const
Print contents of list, defers to Print() function of contained objects.
Definition: RooLinkedList.cxx:716
RooLinkedList::Remove
virtual Bool_t Remove(TObject *arg)
Remove object from collection.
Definition: RooLinkedList.cxx:446
int