16#ifndef ROOFIT_ROOFITCORE_INC_ROOSTLREFCOUNTLIST_H_
17#define ROOFIT_ROOFITCORE_INC_ROOSTLREFCOUNTLIST_H_
59 void Add(T * obj, std::size_t initialCount = 1) {
76 std::size_t
refCount(
typename Container_t::const_iterator item)
const {
84 template<
typename Obj_t>
85 std::size_t
refCount(
const Obj_t * obj)
const {
90 typename Container_t::const_iterator
begin()
const {
95 typename Container_t::const_iterator
end()
const {
100 typename Container_t::value_type
operator[](std::size_t index)
const {
132 template<
typename Obj_t>
133 typename Container_t::const_iterator
findByPointer(
const Obj_t * item)
const {
142 const std::string theName(
name);
143 auto byName = [&theName](
const T * element) {
144 return element->GetName() == theName;
154 auto nptr = item->namePtr();
155 auto byNamePointer = [nptr](
const T * element) {
156 return element->namePtr() == nptr;
160 return found !=
_storage.end() ? *found :
nullptr;
166 if(item->namePtr() != (*first)->namePtr())
return nullptr;
173 template<
typename Obj_t>
194 void Remove(
const T * obj,
bool force =
false) {
198 const std::size_t pos = item -
_storage.begin();
235 [](
const auto&
x,
TNamed const* npt) ->
bool {
236 return x->namePtr() < npt;
253 for(std::size_t i = 0; i <
_storage.size(); ++i) {
257 [](
auto&
a,
auto&
b) {
258 return a->namePtr() != b->namePtr() ? a->namePtr() < b->namePtr() : a < b;
283namespace STLRefCountListHelpers {
#define ClassDef(name, id)
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.
void Remove(const T *obj, bool force=false)
Decrease ref count of given object.
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
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.
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.
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...