81namespace std {}
using namespace std;
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());
314 else if (lnk ==
fFirst.get())
335 auto cached =
fCache.lock();
336 if (cached.get() && cached->GetObject() && cached->GetObject()->IsEqual(obj)) {
375 auto cached =
fCache.lock();
376 if (cached.get() && cached->GetObject() && cached->GetObject()->IsEqual(obj)) {
438 auto obj = tlk->GetObject();
441 Error(
"Clear",
"A list is accessing an object (%p) already deleted (list name = %s)",
443 }
else if (obj->IsOnHeap()) {
474 TList removeDirectory;
500 auto obj = tlk->GetObject();
502 Error(
"Delete",
"A list is accessing an object (%p) already deleted (list name = %s)",
504 else if (obj && obj->IsOnHeap())
506 else if (obj && obj->IsA()->GetDirectoryAutoAdd())
507 removeDirectory.Add(obj);
528 auto obj = tlk->GetObject();
529 tlk->SetObject(
nullptr);
531 Error(
"Delete",
"A list is accessing an object (%p) already deleted (list name = %s)",
533 else if (obj && obj->IsOnHeap())
535 else if (obj && obj->IsA()->GetDirectoryAutoAdd())
536 removeDirectory.Add(obj);
547 TIter iRemDir(&removeDirectory);
549 while ((dirRem = iRemDir())) {
550 (*dirRem->IsA()->GetDirectoryAutoAdd())(dirRem, 0);
559void TList::DeleteLink(
TObjLink *lnk)
585 if (
TObject *obj = lnk->GetObject()) {
586 const char *objname = obj->GetName();
587 if (objname && strcmp(
name, objname) == 0)
615 if (ob->
IsEqual(obj))
return ob;
644 if (object->
IsEqual(obj))
return lnk;
709 while (i < idx && lnk) {
735 auto newlink = std::make_shared<TObjLink>(obj);
750 auto newlink = std::make_shared<TObjOptLink>(obj, opt);
770 auto cached =
fCache.lock();
771 if (cached && cached->fNext.get() ==
nullptr && cached->fPrev.lock().get() ==
nullptr) {
772 TObject *ob = cached->GetObject();
786 TObject *ob = lnk->GetObject();
789 lnk->SetObject(
nullptr);
797 }
else if (lnk ==
fLast) {
798 fLast = lnk->fPrev.lock();
799 fLast->fNext.reset();
802 lnk->Prev()->fNext = next;
803 lnk->Next()->fPrev = lnk->fPrev;
837 if (lnk ==
fFirst.get()) {
841 if (lnk ==
fLast.get()) {
847 }
else if (lnk ==
fLast.get()) {
849 fLast->fNext.reset();
877 if (lnk ==
fFirst.get()) {
881 if (lnk ==
fLast.get()) {
887 }
else if (lnk ==
fLast.get()) {
889 fLast->fNext.reset();
915 if (lnk ==
fFirst.get()) {
920 fLast->fNext.reset();
943 if (!
fFirst->GetObject()->IsSortable()) {
944 Error(
"Sort",
"objects in list are not sortable");
951 std::shared_ptr<TObjLink> ol, lnk =
fFirst;
953 if (lnk.get()) lnk->fPrev.reset();
971 Int_t cmp = l1->GetObject()->Compare(l2->GetObject());
986 std::shared_ptr<TObjLink> p1, p2, *h2, *t2;
993 return &((*head)->fNext);
996 p2 = (p1 = *head)->fNext;
998 p1->fNext = (*head = p2)->fNext;
999 return &((p2->fNext = p1)->fNext);
1009 if (!--
n)
return *h2 = p2, t2;
1010 }
while (
LnkCompare((p1 = *(head = &(p1->fNext))), p2));
1016 if (!--
m)
return *h2 = *t2, *t2 = p1, h2;
1017 }
while (!
LnkCompare(p1, (p2 = *(head = &(p2->fNext)))));
1020 if (!--
n)
return *h2 = p2, t2;
1021 }
while (
LnkCompare((p1 = *(head = &(p1->fNext))), p2));
1034 newlink->fNext = prev->fNext;
1035 newlink->fPrev = prev;
1036 prev->fNext = newlink;
1038 newlink->fNext->fPrev = newlink;
1052 : fList(
l), fCurCursor(0), fCursor(0), fDirection(dir), fStarted(
kFALSE)
1078 if (
this != &rhs && rhs1) {
1112 if (!
fList)
return 0;
1169 if (IsA() == aIter.IsA()) {
1200 if (
b.IsReading()) {
1204 TObject::Streamer(
b);
1208 for (
Int_t i = 0; i < nobjects; i++) {
1211 if (
v > 4 && nch == 255) {
1216 readOption.resize(nbig,
'\0');
1217 b.ReadFastArray((
char*) readOption.data(),nbig);
1220 Add(obj,readOption.c_str());
1226 b.CheckByteCount(R__s, R__c,TList::IsA());
1232 TObject::Streamer(
b);
1236 for (
Int_t i = 0; i < nobjects; i++) {
1240 b.CheckByteCount(R__s, R__c,TList::IsA());
1245 R__c =
b.WriteVersion(TList::IsA(),
kTRUE);
1246 TObject::Streamer(
b);
1269 b.SetByteCount(R__c,
kTRUE);
#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.
virtual const char * GetName() const
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 TIterator & operator=(const TIterator &)
TObject * Next()
Return next object in the list. Returns 0 when no more objects in list.
void Reset()
Reset list iterator.
void SetOption(Option_t *option)
Sets the object option stored in the list.
Bool_t operator!=(const TIterator &aIter) const
This operator compares two TIterator objects.
TIterator & operator=(const TIterator &rhs)
Overridden assignment operator.
Option_t * GetOption() const
Returns the object option stored in the list.
Bool_t LnkCompare(const TObjLinkPtr_t &l1, const TObjLinkPtr_t &l2)
Compares the objects stored in the TObjLink objects.
TObjLinkPtr_t NewOptLink(TObject *obj, Option_t *opt, const TObjLinkPtr_t &prev=nullptr)
Return a new TObjOptLink (a TObjLink that also stores the option).
virtual void Add(TObject *obj)
virtual TObject * After(const TObject *obj) const
Returns the object after object obj.
virtual ~TList()
Delete the list.
Bool_t fAscending
cache to speedup sequential calling of Before() and After() functions
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual TObject ** GetObjectRef(const TObject *obj) const
Return address of pointer to obj.
virtual void AddAt(TObject *obj, Int_t idx)
Insert object at position idx in the list.
TObjLink * FindLink(const TObject *obj, Int_t &idx) const
Returns the TObjLink object that contains object obj.
std::shared_ptr< TObjLink > TObjLinkPtr_t
virtual void AddFirst(TObject *obj)
Add object at the beginning of the list.
TObjLinkPtr_t fLast
pointer to first entry in linked list
void InsertAfter(const TObjLinkPtr_t &newlink, const TObjLinkPtr_t &prev)
Insert a new link in the chain.
virtual void RemoveLast()
Remove the last object of the list.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
TObjLink * LinkAt(Int_t idx) const
sorting order (when calling Sort() or for TSortedList)
virtual TObjLink * FirstLink() const
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
TObjLinkPtr_t NewLink(TObject *obj, const TObjLinkPtr_t &prev=nullptr)
Return a new TObjLink.
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
virtual void AddAfter(const TObject *after, TObject *obj)
Insert object after object after in the list.
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
virtual void AddBefore(const TObject *before, TObject *obj)
Insert object before object before in the list.
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
TObjLinkWeakPtr_t fCache
pointer to last entry in linked list
virtual TObject * Before(const TObject *obj) const
Returns the object before object obj.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
virtual void AddLast(TObject *obj)
Add object at the end of the list.
TObjLinkPtr_t * DoSort(TObjLinkPtr_t *head, Int_t n)
Sort linked list.
virtual void Clear(Option_t *option="")
Remove all objects from 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).
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void RecursiveRemove(TObject *obj)
Recursively remove this object from a list.
@ kNotDeleted
object has not been deleted
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
@ kCanDelete
if object in a list can be deleted
R__EXTERN TVirtualRWMutex * gCoreMutex