125 typedef std::map<const void*, Chunk*>
AddrMap;
186 AddrMap::iterator ci =
_addrmap.end();
195 if (
_addrmap.begin() != ci && ci->first != el) --ci;
200 if (
_addrmap.empty() || !ci->second->contains(el)) {
206 const bool moveToFreelist =
c->
full();
207 c->push_free_elem(el);
215 }
else if (moveToFreelist) {
265 _hashThresh(htsize), _size(0), _first(0), _last(0), _htableName(nullptr), _htableLink(nullptr), _useNptr(true)
275 TObject(other), _hashThresh(other._hashThresh), _size(0), _first(0), _last(0), _htableName(nullptr), _htableLink(nullptr),
277 _useNptr(other._useNptr)
284 Add(elem->_arg, elem->_refCount) ;
294 ret->
init(obj, elem);
313 if (&other==
this)
return *this ;
332 coutE(InputArguments) <<
"RooLinkedList::setHashTable() ERROR size must be positive" << endl ;
391 if (ptr->
_arg == arg) {
451 if (!elem)
return false ;
466 auto at_elem_it = std::find(
_at.begin(),
_at.end(), elem);
467 _at.erase(at_elem_it);
491 if (index<0 || index>=
_size)
return 0 ;
493 return _at[index]->_arg;
512 if (!elem)
return false ;
544 return elem ? elem->
_arg : 0 ;
638 if (!nptr)
return nullptr;
693 if (ptr->
_arg==arg)
return idx ;
724 cout << elem->
_arg <<
" : " ;
736 auto iterImpl = std::make_unique<RooLinkedListIterImpl>(
this, forward);
746 auto iterImpl = std::make_unique<RooLinkedListIterImpl>(
this, forward);
755 auto iterImpl = std::make_unique<RooFIterForLinkedList>(
this);
756 return RooFIter(std::move(iterImpl));
764 return {
this,
nullptr,
true};
768 return {
this,
false};
772 return {
this,
nullptr,
false};
784 for (
auto it =
_at.begin(); it !=
_at.end(); ++it, elem = elem->
_next) {
792template <
bool ascending>
798 if (tail) *tail = l1;
803 std::vector<RooLinkedListElem *> arr(sz,
nullptr);
804 for (
int i = 0; l1; l1 = l1->
_next, ++i) arr[i] = l1;
812 const bool inOrder = ascending ?
814 (arr[j]->_arg->Compare(tmp->
_arg) <= 0);
821 }
while (
int(sz) != i);
824 arr[0]->_prev = arr[sz - 1]->_next = 0;
825 for (
int i = 0; i <
int(sz - 1); ++i) {
826 arr[i]->_next = arr[i + 1];
827 arr[i + 1]->_prev = arr[i];
829 if (tail) *tail = arr[sz - 1];
837 if (!
end->_next)
break;
843 if (l1->
_next) l1 = mergesort_impl<ascending>(l1, sz / 2);
844 if (l2->
_next) l2 = mergesort_impl<ascending>(l2, sz - sz / 2);
877 if (t) t->
_next = l2;
881 for (l1 = t; l1; l1 = l1->
_next) t = l1;
901void RooLinkedList::Streamer(
TBuffer &R__b)
907 TObject::Streamer(R__b);
918 if (
v > 1 &&
v < 4) {
924 TObject::Streamer(R__b);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
const TNamed * namePtr() const
De-duplicated pointer to this object's name.
RooAbsData is the common abstract base class for binned and unbinned datasets.
const TNamed * namePtr() const
De-duplicated pointer to this object's name.
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooLinkedListElem is an link element for the RooLinkedList class.
void init(TObject *arg, RooLinkedListElem *after=0)
RooLinkedListElem * _prev
RooLinkedListElem * _next
a chunk of memory in a pool for quick allocation of RooLinkedListElems
bool full() const
chunk full?
RooLinkedListElem * _freelist
list of free elements
void push_free_elem(RooLinkedListElem *el)
push a free element back onto the freelist
Chunk(const Chunk &)
forbid copying
bool empty() const
chunk empty?
RooLinkedListElem * pop_free_elem()
pop a free element off the free list
Chunk(Int_t sz)
constructor
const void * chunkaddr() const
return address of chunk
Int_t size() const
chunk occupied elements
Int_t capacity() const
chunk capacity
Int_t free() const
chunk free elements
int szclass() const
return size class
Chunk & operator=(const Chunk &)
bool contains(RooLinkedListElem *el) const
check if el is in this chunk
Int_t _free
length of free list
RooLinkedListElem * _chunk
chunk from which elements come
UInt_t _szmap[(maxsz - minsz)/szincr]
bool release()
release the pool, return true if the pool is unused
void push_free_elem(RooLinkedListElem *el)
push a free element back into the pool
Int_t nextChunkSz() const
find size of next chunk to allocate (in a hopefully smart way)
void updateCurSz(Int_t sz, Int_t incr)
adjust _cursz to current largest block
void acquire()
acquire the pool
std::map< const void *, Chunk * > AddrMap
std::list< Chunk * > ChunkList
RooLinkedListElem * pop_free_elem()
pop a free element out of the pool
@ maxsz
maximum chunk size (just below 1 << maxsz bytes)
@ minsz
minimum chunk size (just below 1 << minsz bytes)
@ szincr
size class increment (sz = 1 << (minsz + k * szincr))
RooLinkedListImplDetails::Chunk Chunk
a chunk of memory in the pool
Implementation of the actual iterator on RooLinkedLists.
A wrapper around TIterator derivatives.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
RooLinkedListIterImpl rend() const
TObject * At(int index) const
Return object stored in sequential position given by index.
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
static Pool * _pool
shared memory pool for allocation of RooLinkedListElems
TString _name
Hash table by link pointer.
RooLinkedListIterImpl end() const
RooLinkedListImplDetails::Pool Pool
memory pool for quick allocation of RooLinkedListElems
std::vector< RooLinkedListElem * > _at
RooLinkedListIter iterator(Bool_t forward=kTRUE) const
Create an iterator for this list.
std::unique_ptr< HashTableByName > _htableName
RooLinkedListElem * createElement(TObject *obj, RooLinkedListElem *elem=0)
cout << "RooLinkedList::createElem(" << this << ") obj = " << obj << " elem = " << elem << endl ;
RooLinkedList(Int_t htsize=0)
std::unique_ptr< HashTableByLink > _htableLink
Hash table by name.
void Sort(Bool_t ascend=kTRUE)
RooFIter fwdIterator() const
Create a one-time-use forward iterator for this list.
void deleteElement(RooLinkedListElem *)
RooLinkedListElem * findLink(const TObject *arg) const
Find the element link containing the given object.
void Print(const char *opt) const
Print contents of list, defers to Print() function of contained objects.
RooLinkedListIterImpl rbegin() const
TIterator * MakeIterator(Bool_t forward=kTRUE) const
Create a TIterator for this list.
static RooLinkedListElem * mergesort_impl(RooLinkedListElem *l1, const unsigned sz, RooLinkedListElem **tail=0)
length 0, 1 lists are sorted
RooAbsArg * findArg(const RooAbsArg *) const
Return pointer to object with given name in collection.
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
TObject * find(const char *name) const
Return pointer to object with given name in collection.
RooLinkedList & operator=(const RooLinkedList &other)
Assignment operator, copy contents from 'other'.
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
virtual void Add(TObject *arg)
RooLinkedListIterImpl begin() const
RooLinkedListElem * _last
Link to first element of list.
void setHashTableSize(Int_t size)
Change the threshold for hash-table use to given size.
void Clear(Option_t *o=0)
Remove all elements from collection.
Bool_t Replace(const TObject *oldArg, const TObject *newArg)
Replace object 'oldArg' in collection with new object 'newArg'.
RooLinkedListElem * _first
virtual Bool_t Remove(TObject *arg)
Remove object from collection.
Int_t IndexOf(const char *name) const
Return position of given object in list.
virtual ~RooLinkedList()
Destructor.
static const TNamed * known(const char *stringPtr)
If the name is already known, return its TNamed pointer. Otherwise return 0 (don't register the name)...
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
Iterator abstract base class.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual Int_t Compare(const TObject *obj) const
Compare abstract method.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.