Logo ROOT   6.10/09
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 
22 #include "TNamed.h"
23 #include "RooLinkedListElem.h"
24 #include "RooHashTable.h"
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) ;
66  TIterator* MakeIterator(Bool_t dir=kTRUE) const ;
67  RooLinkedListIter iterator(Bool_t dir=kTRUE) const ;
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  void Print(const char* opt) const ;
83  void Sort(Bool_t ascend=kTRUE) ;
84 
85  // const char* GetName() const { return "" ; /*_name.Data() ; */ }
86  // void SetName(const char* /*name*/) { /*_name = name ; */ }
87  const char* GetName() const { return _name.Data() ; }
88  void SetName(const char* name) { _name = name ; }
89 
90  void useNptr(Bool_t flag) { _useNptr = flag ; }
91  // needed for using it in THashList/THashTable
92 
93  ULong_t Hash() const { return _name.Hash(); }
94  //ULong_t Hash() const { return TString().Hash(); }
95 
96 protected:
97 
98  RooLinkedListElem* createElement(TObject* obj, RooLinkedListElem* elem=0) ;
99  void deleteElement(RooLinkedListElem*) ;
100 
101 
102  friend class RooLinkedListIter ;
103  friend class RooFIter ;
104 
105  virtual void Add(TObject* arg, Int_t refCount) ;
106 
107  RooLinkedListElem* findLink(const TObject* arg) const ;
108 
109  Int_t _hashThresh ; // Size threshold for hashing
110  Int_t _size ; // Current size of list
111  RooLinkedListElem* _first ; //! Link to first element of list
112  RooLinkedListElem* _last ; //! Link to last element of list
113  RooHashTable* _htableName ; //! Hash table by name
114  RooHashTable* _htableLink ; //! Hash table by link pointer
115 
118 
119 private:
120  template <bool ascending>
121  static RooLinkedListElem* mergesort_impl(RooLinkedListElem* l1,
122  const unsigned sz, RooLinkedListElem** tail = 0);
123  /// memory pool for quick allocation of RooLinkedListElems
124  typedef RooLinkedListImplDetails::Pool Pool;
125  /// shared memory pool for allocation of RooLinkedListElems
126  static Pool* _pool; //!
127 
128  ClassDef(RooLinkedList,3) // Doubly linked list for storage of RooAbsArg objects
129 };
130 
131 
132 
133 
134 #endif
const char * GetName() const
Returns name of object.
Definition: RooLinkedList.h:87
RooHashTable * _htableLink
Hash table by name.
ULong_t Hash() const
Return hash value for this object.
Definition: RooLinkedList.h:93
const char Option_t
Definition: RtypesCore.h:62
Basic string class.
Definition: TString.h:129
virtual TObject * Clone(const char *=0) const
Make a clone of an object using the Streamer facility.
Definition: RooLinkedList.h:43
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t getHashTableSize() const
Definition: RooLinkedList.h:50
RooLinkedListImplDetails::Pool Pool
memory pool for quick allocation of RooLinkedListElems
void SetName(const char *name)
Definition: RooLinkedList.h:88
TObject * First() const
Definition: RooLinkedList.h:78
Int_t GetSize() const
Definition: RooLinkedList.h:60
Iterator abstract base class.
Definition: TIterator.h:30
#define ClassDef(name, id)
Definition: Rtypes.h:297
RooLinkedListElem * _first
TString _name
Hash table by link pointer.
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Definition: TMath.h:1151
RooHashTable implements a hash table for TObjects.
Definition: RooHashTable.h:28
void useNptr(Bool_t flag)
Definition: RooLinkedList.h:90
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:62
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:35
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, const THist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
Definition: THist.hxx:336
void Print(std::ostream &os, const OptionType &opt)
unsigned long ULong_t
Definition: RtypesCore.h:51
Binding & operator=(OUT(*fun)(void))
Mother of all ROOT objects.
Definition: TObject.h:37
RooLinkedListElem * _last
Link to first element of list.
static Pool * _pool
shared memory pool for allocation of RooLinkedListElems
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:66
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooLinkedListIter is the TIterator implementation for RooLinkedList.
RooHashTable * _htableName
Link to last element of list.