#include "TSortedList.h"
ClassImp(TSortedList)
void TSortedList::Add(TObject *obj)
{
if (IsArgNull("Add", obj)) return;
if (!obj->IsSortable()) {
Error("Add", "object must be sortable");
return;
}
if (!fFirst) {
TList::AddLast(obj);
return;
}
TObjLink *lnk = fFirst;
while (lnk) {
Int_t cmp = lnk->GetObject()->Compare(obj);
if ((IsAscending() && cmp > 0) || (!IsAscending() && cmp < 0)) {
if (lnk->Prev()) {
NewLink(obj, lnk->Prev());
fSize++;
return;
} else {
TList::AddFirst(obj);
return;
}
}
lnk = lnk->Next();
}
TList::AddLast(obj);
}
void TSortedList::Add(TObject *obj, Option_t *opt)
{
if (IsArgNull("Add", obj)) return;
if (!obj->IsSortable()) {
Error("Add", "object must be sortable");
return;
}
if (!fFirst) {
TList::Add(obj, opt);
return;
}
TObjLink *lnk = fFirst;
while (lnk) {
Int_t cmp = lnk->GetObject()->Compare(obj);
if ((IsAscending() && cmp > 0) || (!IsAscending() && cmp < 0)) {
if (lnk->Prev()) {
NewOptLink(obj, opt, lnk);
fSize++;
return;
} else {
TList::AddFirst(obj, opt);
return;
}
}
lnk = lnk->Next();
}
TList::Add(obj, opt);
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.