File indexing completed on 2025-12-13 10:27:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROO_LINKED_LIST
0017 #define ROO_LINKED_LIST
0018
0019 #include "TObject.h"
0020 #include "RooLinkedListElem.h"
0021 #include "TString.h"
0022
0023 #include <vector>
0024 #include <memory>
0025 #include <unordered_map>
0026
0027 class RooLinkedListIter ;
0028 class RooLinkedListIterImpl ;
0029 class RooFIter;
0030 class TIterator ;
0031 class RooAbsArg ;
0032
0033
0034
0035 template<class T>
0036 class RooSTLRefCountList;
0037
0038 namespace RooLinkedListImplDetails {
0039 class Chunk;
0040 class Pool;
0041 }
0042
0043
0044
0045 class RooLinkedList : public TObject {
0046 public:
0047
0048 RooLinkedList(Int_t htsize=0) ;
0049
0050
0051 RooLinkedList(const RooLinkedList& other) ;
0052
0053 TObject* Clone(const char* =nullptr) const override {
0054 return new RooLinkedList(*this) ;
0055 }
0056
0057
0058 RooLinkedList& operator=(const RooLinkedList& other) ;
0059
0060 Int_t getHashTableSize() const {
0061
0062 return _htableName ? _htableName->size() : 0 ;
0063 }
0064
0065 void setHashTableSize(Int_t size) ;
0066
0067
0068 ~RooLinkedList() override ;
0069
0070 Int_t GetSize() const { return _size ; }
0071 std::size_t size() const { return _size ; }
0072 bool empty() const { return _size == 0 ; }
0073
0074 virtual void Add(TObject* arg) { Add(arg,1) ; }
0075 virtual bool Remove(TObject* arg) ;
0076 TObject* At(int index) const ;
0077 bool Replace(const TObject* oldArg, const TObject* newArg) ;
0078 TIterator* MakeIterator(bool forward = true) const ;
0079 RooLinkedListIter iterator(bool forward = true) const ;
0080 RooFIter fwdIterator() const ;
0081 RooLinkedListIterImpl begin() const;
0082 RooLinkedListIterImpl end() const;
0083 RooLinkedListIterImpl rbegin() const;
0084 RooLinkedListIterImpl rend() const;
0085
0086 void Clear(Option_t *o=nullptr) override ;
0087 void Delete(Option_t *o=nullptr) override ;
0088 TObject* find(const char* name) const ;
0089 RooAbsArg* findArg(const RooAbsArg*) const ;
0090 TObject* FindObject(const char* name) const override ;
0091 TObject* FindObject(const TObject* obj) const override ;
0092 Int_t IndexOf(const char* name) const ;
0093 Int_t IndexOf(const TObject* arg) const ;
0094 TObject* First() const {
0095 return _first ? _first->_arg : nullptr ;
0096 }
0097
0098
0099 bool contains(const char* name) const { return find(name); }
0100
0101 void RecursiveRemove(TObject *obj) override;
0102
0103 void Print(const char* opt) const override ;
0104 void Sort(bool ascend=true) ;
0105
0106
0107
0108 const char* GetName() const override { return _name.Data() ; }
0109 void SetName(const char* name) { _name = name ; }
0110
0111 void useNptr(bool flag) { _useNptr = flag ; }
0112
0113
0114 ULong_t Hash() const override { return _name.Hash(); }
0115
0116 protected:
0117
0118 RooLinkedListElem* createElement(TObject* obj, RooLinkedListElem* elem=nullptr) ;
0119 void deleteElement(RooLinkedListElem*) ;
0120
0121
0122 template<class T> friend class RooSTLRefCountList;
0123
0124 friend class RooLinkedListIterImpl ;
0125 friend class RooFIterForLinkedList ;
0126
0127 virtual void Add(TObject* arg, Int_t refCount) ;
0128
0129 RooLinkedListElem* findLink(const TObject* arg) const ;
0130
0131 Int_t _hashThresh ;
0132 Int_t _size ;
0133 RooLinkedListElem* _first ;
0134 RooLinkedListElem* _last ;
0135
0136 using HashTableByName = std::unordered_map<std::string,TObject const*>;
0137 using HashTableByLink = std::unordered_map<TObject const*,TObject const*>;
0138 std::unique_ptr<HashTableByName> _htableName;
0139 std::unique_ptr<HashTableByLink> _htableLink;
0140
0141 TString _name ;
0142 bool _useNptr ;
0143
0144 private:
0145 template <bool ascending>
0146 static RooLinkedListElem* mergesort_impl(RooLinkedListElem* l1,
0147 const unsigned sz, RooLinkedListElem** tail = nullptr);
0148
0149 typedef RooLinkedListImplDetails::Pool Pool;
0150
0151 static Pool* _pool;
0152
0153 std::vector<RooLinkedListElem *> _at;
0154
0155 ClassDefOverride(RooLinkedList,3)
0156 };
0157
0158 #endif