16#ifndef ROOFIT_ROOFITCORE_INC_ROOSTLREFCOUNTLIST_H_
17#define ROOFIT_ROOFITCORE_INC_ROOSTLREFCOUNTLIST_H_
59 void Add(T * obj, std::size_t initialCount = 1) {
61 if(initialCount == 0)
return;
79 std::size_t
refCount(
typename Container_t::const_iterator item)
const {
87 template<
typename Obj_t>
88 std::size_t
refCount(
const Obj_t * obj)
const {
93 typename Container_t::const_iterator
begin()
const {
98 typename Container_t::const_iterator
end()
const {
135 template<
typename Obj_t>
136 typename Container_t::const_iterator
findByPointer(
const Obj_t * item)
const {
145 const std::string theName(
name);
146 auto byName = [&theName](
const T * element) {
147 return element->GetName() == theName;
161 auto byNamePointer = [namePtr](
const T * element) {
162 return element->namePtr() == namePtr;
166 return found !=
_storage.end() ? *found :
nullptr;
172 if(namePtr != (*first)->namePtr())
return nullptr;
179 template<
typename Obj_t>
204 int Remove(
const T * obj,
bool force =
false) {
208 const std::size_t pos = item -
_storage.begin();
243 const std::size_t pos = item -
_storage.begin();
274 [](
const auto&
x,
TNamed const* npt) ->
bool {
275 return x->namePtr() < npt;
292 for(std::size_t i = 0; i <
_storage.size(); ++i) {
296 [](
auto&
a,
auto&
b) {
297 return a->namePtr() != b->namePtr() ? a->namePtr() < b->namePtr() : a < b;
322namespace STLRefCountListHelpers {
#define ClassDef(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
static const std::size_t & renameCounter()
renamed in this RooFit process.
A RooRefCountList is a RooLinkedList that keeps a reference counter with each added node.
The RooSTLRefCountList is a simple collection of pointers to the template objects with reference coun...
void initializeOrderedStorage() const
std::size_t refCount(typename Container_t::const_iterator item) const
Return ref count of item that iterator points to.
virtual ~RooSTLRefCountList()
bool containsSameName(const char *name) const
Check if list contains an item using findByName().
bool orderedStorageNeedsSorting() const
std::vector< T * >::const_iterator lowerBoundByNamePointer(const T *item) const
bool containsByPointer(const Obj_t *obj) const
Check if list contains an item using findByPointer().
std::size_t refCount(const Obj_t *obj) const
Return ref count of item with given address.
T * findByNamePointer(const T *item) const
Find an item by comparing RooAbsArg::namePtr() adresses.
const Container_t & containedObjects() const
Direct reference to container of objects held by this list.
Container_t::const_iterator begin() const
Iterator over contained objects.
unsigned long _renameCounterForLastSorting
!
std::vector< T * > Container_t
void Add(T *obj, std::size_t initialCount=1)
Add an object or increase refCount if it is already present.
std::vector< T * > _orderedStorage
RooSTLRefCountList & operator=(RooSTLRefCountList &&)=default
int Replace(const T *oldObj, T *newObj)
Replace an element with a new value, keeping the same refCount.
Container_t::value_type operator[](std::size_t index) const
Retrieve an element from the list.
static std::size_t const * _renameCounter
RooSTLRefCountList & operator=(const RooSTLRefCountList &)=default
RooSTLRefCountList(const RooSTLRefCountList &)=default
Container_t::const_iterator end() const
End of contained objects.
std::vector< T * >::const_iterator lowerBoundByNamePointer(TNamed const *namePtr) const
bool empty() const
Check if empty.
static constexpr std::size_t minSizeForNamePointerOrdering
std::vector< UInt_t > _refCount
Container_t::const_iterator findByName(const char *name) const
Find an item by comparing strings returned by RooAbsArg::GetName()
std::size_t size() const
Number of contained objects (neglecting the ref count).
Container_t::const_iterator findByPointer(const Obj_t *item) const
Find an item by comparing its adress.
int Remove(const T *obj, bool force=false)
Decrease ref count of given object.
T * findByNamePointer(TNamed const *namePtr) const
void RemoveAll(const T *obj)
Remove from list irrespective of ref count.
void reserve(std::size_t amount)
bool containsByNamePtr(const T *obj) const
Check if list contains an item using findByNamePointer().
The TNamed class is the base class for all named ROOT classes.
RooSTLRefCountList< RooAbsArg > convert(const RooRefCountList &old)
Converter from the old RooRefCountList to RooSTLRefCountList.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...