207 Error(
"AddBefore",
"before not found, object not added");
234 if (before ==
fFirst.get())
261 Error(
"AddAfter",
"after not found, object not added");
264 if (t ==
fLast.get())
267 NewLink(obj, t->shared_from_this());
290 if (after ==
fLast.get())
293 NewLink(obj, after->shared_from_this());
317 Error(
"AddBefore",
"before not found, object not added");
344 if (before ==
fFirst.get())
371 Error(
"AddAfter",
"after not found, object not added");
374 if (t ==
fLast.get())
400 if (after ==
fLast.get())
403 NewOptLink(obj, opt, after->shared_from_this());
424 else if (lnk ==
fFirst.get())
447 else if (lnk ==
fFirst.get())
468 auto cached =
fCache.lock();
469 if (cached.get() && cached->GetObject() && cached->GetObject()->IsEqual(obj)) {
508 auto cached =
fCache.lock();
509 if (cached.get() && cached->GetObject() && cached->GetObject()->IsEqual(obj)) {
571 auto obj = tlk->GetObject();
574 Error(
"Clear",
"A list is accessing an object (%p) already deleted (list name = %s)",
576 }
else if (obj->IsOnHeap()) {
607 TList removeDirectory;
633 auto obj = tlk->GetObject();
635 Error(
"Delete",
"A list is accessing an object (%p) already deleted (list name = %s)",
637 else if (obj && obj->IsOnHeap())
639 else if (obj && obj->IsA()->GetDirectoryAutoAdd())
640 removeDirectory.
Add(obj);
659 first = first->fNext;
661 auto obj = tlk->GetObject();
662 tlk->SetObject(
nullptr);
664 Error(
"Delete",
"A list is accessing an object (%p) already deleted (list name = %s)",
666 else if (obj && obj->IsOnHeap())
668 else if (obj && obj->IsA()->GetDirectoryAutoAdd())
669 removeDirectory.
Add(obj);
680 TIter iRemDir(&removeDirectory);
682 while ((dirRem = iRemDir())) {
683 (*dirRem->
IsA()->GetDirectoryAutoAdd())(dirRem,
nullptr);
692void TList::DeleteLink(
TObjLink *lnk)
718 if (
TObject *obj = lnk->GetObject()) {
719 const char *objname = obj->GetName();
720 if (objname && strcmp(
name, objname) == 0)
748 if (ob->
IsEqual(obj))
return ob;
767 if (!
fFirst)
return nullptr;
777 if (
object->IsEqual(obj))
return lnk;
842 while (i < idx && lnk) {
868 auto newlink = std::make_shared<TObjLink>(obj);
883 auto newlink = std::make_shared<TObjOptLink>(obj, opt);
906 auto cached =
fCache.lock();
907 if (cached && cached->fNext.get() ==
nullptr && cached->fPrev.lock().get() ==
nullptr) {
908 TObject *ob = cached->GetObject();
919 TObject *ob = lnk->GetObject();
922 lnk->SetObject(
nullptr);
930 }
else if (lnk ==
fLast) {
931 fLast = lnk->fPrev.lock();
932 fLast->fNext.reset();
935 lnk->Prev()->fNext = next;
936 lnk->Next()->fPrev = lnk->fPrev;
956 if (!obj)
return nullptr;
961 if (!lnk)
return nullptr;
970 if (lnk ==
fFirst.get()) {
974 if (lnk ==
fLast.get()) {
980 }
else if (lnk ==
fLast.get()) {
982 fLast->fNext.reset();
1004 if (!lnk)
return nullptr;
1010 if (lnk ==
fFirst.get()) {
1014 if (lnk ==
fLast.get()) {
1020 }
else if (lnk ==
fLast.get()) {
1022 fLast->fNext.reset();
1048 if (lnk ==
fFirst.get()) {
1053 fLast->fNext.reset();
1076 if (!
fFirst->GetObject()->IsSortable()) {
1077 Error(
"Sort",
"objects in list are not sortable");
1084 std::shared_ptr<TObjLink> ol, lnk =
fFirst;
1086 if (lnk.get()) lnk->fPrev.reset();
1087 while ((ol = lnk)) {
1104 Int_t cmp = l1->GetObject()->Compare(l2->GetObject());
1119 std::shared_ptr<TObjLink> p1, p2, *h2, *t2;
1126 return &((*head)->fNext);
1129 p2 = (p1 = *head)->fNext;
1131 p1->fNext = (*head = p2)->fNext;
1132 return &((p2->fNext = p1)->fNext);
1142 if (!--
n)
return *h2 = p2, t2;
1143 }
while (
LnkCompare((p1 = *(head = &(p1->fNext))), p2));
1149 if (!--
m)
return *h2 = *t2, *t2 = p1, h2;
1150 }
while (!
LnkCompare(p1, (p2 = *(head = &(p2->fNext)))));
1153 if (!--
n)
return *h2 = p2, t2;
1154 }
while (
LnkCompare((p1 = *(head = &(p1->fNext))), p2));
1167 newlink->fNext = prev->fNext;
1168 newlink->fPrev = prev;
1169 prev->fNext = newlink;
1171 newlink->fNext->fPrev = newlink;
1213 if (
this != &rhs && rhs1) {
1245 if (!
fList)
return nullptr;
1302 if (
IsA() == aIter.
IsA()) {
1333 if (
b.IsReading()) {
1340 std::string readOption;
1341 for (
Int_t i = 0; i < nobjects; i++) {
1344 if (
v > 4 && nch == 255) {
1349 readOption.resize(nbig,
'\0');
1350 b.ReadFastArray((
char*) readOption.data(),nbig);
1353 Add(obj,readOption.c_str());
1369 for (
Int_t i = 0; i < nobjects; i++) {
1402 b.SetByteCount(R__c,
kTRUE);
int Int_t
Signed integer 4 bytes (int).
short Version_t
Class version identifier (short).
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
const char Option_t
Option string (const char).
#define R__COLLECTION_READ_LOCKGUARD(mutex)
#define R__COLLECTION_WRITE_GUARD()
#define R__COLLECTION_READ_GUARD()
const Bool_t kIterForward
#define R__COLLECTION_ITER_GUARD(collection)
#define R__COLLECTION_WRITE_LOCKGUARD(mutex)
Buffer base class used for serializing objects.
Bool_t IsArgNull(const char *where, const TObject *obj) const
Returns true if object is a null pointer.
const char * GetName() const override
Return name of this collection.
static void GarbageCollect(TObject *obj)
Add to the list of things to be cleaned up.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Iterator abstract base class.
virtual TClass * IsA() const
Option_t * GetOption() const override
Returns the object option stored in the list.
void Reset() override
Reset list iterator.
TObject * Next() override
Return next object in the list. Returns 0 when no more objects in list.
TIterator & operator=(const TIterator &rhs) override
Overridden assignment operator.
void SetOption(Option_t *option)
Sets the object option stored in the list.
Bool_t operator!=(const TIterator &aIter) const override
This operator compares two TIterator objects.
TClass * IsA() const override
Bool_t LnkCompare(const TObjLinkPtr_t &l1, const TObjLinkPtr_t &l2)
Compares the objects stored in the TObjLink objects.
void Streamer(TBuffer &) override
Stream all objects in the collection to or from the I/O buffer.
void AddAfter(const TObject *after, TObject *obj) override
Insert object after object after in the list.
TObject * After(const TObject *obj) const override
Returns the object after object obj.
TObjLinkPtr_t NewOptLink(TObject *obj, Option_t *opt, const TObjLinkPtr_t &prev=nullptr)
Return a new TObjOptLink (a TObjLink that also stores the option).
void Clear(Option_t *option="") override
Remove all objects from the list.
TObject ** GetObjectRef(const TObject *obj) const override
Return address of pointer to obj.
TList(const TList &)=delete
virtual ~TList()
Delete the list.
Bool_t fAscending
! sorting order (when calling Sort() or for TSortedList)
void AddAt(TObject *obj, Int_t idx) override
Insert object at position idx in the list.
TObject * Before(const TObject *obj) const override
Returns the object before object obj.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
TObjLink * FindLink(const TObject *obj, Int_t &idx) const
Returns the TObjLink object that contains object obj.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
void AddLast(TObject *obj) override
Add object at the end of the list.
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
std::shared_ptr< TObjLink > TObjLinkPtr_t
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
TObjLinkPtr_t fLast
! pointer to last entry in linked list
void InsertAfter(const TObjLinkPtr_t &newlink, const TObjLinkPtr_t &prev)
Insert a new link in the chain.
TIterator * MakeIterator(Bool_t dir=kIterForward) const override
Return a list iterator.
void AddBefore(const TObject *before, TObject *obj) override
Insert object before object before in the list.
TObjLink * LinkAt(Int_t idx) const
Return the TObjLink object at index idx.
virtual TObjLink * FirstLink() const
TObjLinkPtr_t NewLink(TObject *obj, const TObjLinkPtr_t &prev=nullptr)
Return a new TObjLink.
TObjLinkPtr_t fFirst
! pointer to first entry in linked list
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
TObjLinkWeakPtr_t fCache
! cache to speedup sequential calling of Before() and After() functions
TClass * IsA() const override
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
void RemoveLast() override
Remove the last object of the list.
TObjLinkPtr_t * DoSort(TObjLinkPtr_t *head, Int_t n)
Sort linked list.
void AddFirst(TObject *obj) override
Add object at the beginning of the list.
virtual void Sort(Bool_t order=kSortAscending)
Sort linked list.
Wrapper around a TObject so it can be stored in a TList.
void SetObject(TObject *obj)
TObject ** GetObjectRef()
virtual Option_t * GetAddOption() const
TObject * GetObject() const
Mother of all ROOT objects.
virtual Bool_t IsEqual(const TObject *obj) const
Default equal comparison (objects are equal if they have the same address in memory).
virtual void RecursiveRemove(TObject *obj)
Recursively remove this object from a list.
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual TClass * IsA() const
TObject()
TObject constructor.
@ kCanDelete
if object in a list can be deleted
bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
externTVirtualRWMutex * gCoreMutex