67 Warning(
"TObjArray",
"size (%d) < 0", s);
81 Init(
a.fSize,
a.fLowerBound);
116 Init(
a.fSize,
a.fLowerBound);
136 if (j >= 0 && j <
fSize) {
198 Error(
"AddBefore",
"before not found, object not added");
224 Error(
"AddAfter",
"after not found, object not added");
240 Error(
"AddAt",
"out of bounds at %d in %zx", idx, (
size_t)
this);
258 if (!
BoundsOk(
"AddAt", idx))
return;
275 for (i = 0; i <
fSize; i++)
297 if (idx == -1 || idx ==
fSize-1)
return 0;
312 if (idx == -1 || idx == 0)
return 0;
349 for ( ; j <
fSize; j++)
392 Error (
"Expand",
"newSize must be positive (%d)", newSize);
395 if (newSize ==
fSize)
397 if (newSize <
fSize) {
401 Error (
"Expand",
"expand would cut off nonempty entries at %d", j);
420 for (
Int_t i = 0; i < nobjects; ++i) {
422 if (obj && 0==strcmp(
name, obj->
GetName()))
return obj;
439 for (
Int_t i = 0; i < nobjects; ++i) {
441 if (obj && obj->
IsEqual(iobj))
return obj;
456 TObject::Streamer(
b);
467 for (
Int_t i = 0; i < nobjects; i++) {
468 obj = (
TObject*)
b.ReadObjectAny(TObject::Class());
475 b.CheckByteCount(R__s, R__c,TObjArray::IsA());
479 R__c =
b.WriteVersion(TObjArray::IsA(),
kTRUE);
480 TObject::Streamer(
b);
486 for (
Int_t i = 0; i < nobjects; i++) {
489 b.SetByteCount(R__c,
kTRUE);
595 return &
fCont[index];
612 for (i = 0; i <
fSize; i++)
616 for (i = 0; i <
fSize; i++)
660 Error(where,
"index %d out of bounds (size: %d, this: 0x%zx)", i,
fSize, (
size_t)
this);
677 for (
int i = 0; i <
fSize; i++) {
696 if (!
BoundsOk(
"RemoveAt", idx))
return 0;
727 if (idx == -1)
return 0;
745 if (!
BoundsOk(
"RemoveRange", idx1))
return;
746 if (!
BoundsOk(
"RemoveRange", idx2))
return;
763 if (idx1 < fLast || fLast > idx2)
return;
779 if (last == -2 || last == -1)
799 for (
Int_t i = 0; i < ntimes; i++) {
806 if (k == j)
continue;
826 Error(
"Sort",
"objects in array are not sortable");
845 Int_t base, position, last, result = 0;
851 Error(
"BinarySearch",
"array must first be sorted");
858 while (last >= base) {
859 position = (base+last) / 2;
860 op2 =
fCont[position];
861 if (op2 && (result = op->
Compare(op2)) == 0)
863 if (!op2 || result < 0)
904 if (
this != &rhs && rhs.IsA() == TObjArrayIter::Class()) {
938 if (fCursor < fArray->Capacity()) {
971 if (aIter.IsA() == TObjArrayIter::Class()) {
991 return (((
fCurCursor >= 0) && (fCurCursor < fArray->Capacity())) ?
#define R__unlikely(expr)
#define R__COLLECTION_READ_LOCKGUARD(mutex)
const Bool_t kIterForward
#define R__COLLECTION_WRITE_LOCKGUARD(mutex)
Buffer base class used for serializing objects.
Bool_t IsSortable() const
virtual Int_t GrowBy(Int_t delta) const
Increase the collection's capacity by delta slots.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
static void GarbageCollect(TObject *obj)
Add to the list of things to be cleaned up.
Iterator abstract base class.
Iterator of object array.
Bool_t operator!=(const TIterator &aIter) const
This operator compares two TIterator objects.
void Reset()
Reset array iterator.
TIterator & operator=(const TIterator &rhs)
Overridden assignment operator.
TObject * operator*() const
Return current object or nullptr.
TObject * Next()
Return next object in array. Returns 0 when no more objects in array.
virtual Int_t AddAtFree(TObject *obj)
Return the position of the new object.
TObjArray & operator=(const TObjArray &)
Assignment operator. Note, unsets the kIsOwner flag.
Int_t IndexOf(const TObject *obj) const
Int_t GetEntriesFast() const
virtual void Expand(Int_t newSize)
Expand or shrink the array to newSize elements.
Int_t GetEntriesUnsafe() const
Return the number of objects in array (i.e.
virtual TObject *& operator[](Int_t i)
Return the object at position i.
TObject ** GetObjectRef() const
virtual ~TObjArray()
Delete an array.
void Init(Int_t s, Int_t lowerBound)
Initialize a TObjArray.
virtual void Sort(Int_t upto=kMaxInt)
If objects in array are sortable (i.e.
virtual void AddLast(TObject *obj)
Add object in the next empty slot in the array.
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
virtual void AddAfter(const TObject *after, TObject *obj)
Add object in the slot after object after.
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
virtual void Compress()
Remove empty slots from array.
Bool_t BoundsOk(const char *where, Int_t at) const
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual void Clear(Option_t *option="")
Remove all objects from the array.
Bool_t OutOfBoundsError(const char *where, Int_t i) const
Generate an out-of-bounds error. Always returns false.
virtual Int_t BinarySearch(TObject *obj, Int_t upto=kMaxInt)
Find object using a binary search.
TObject * After(const TObject *obj) const
Return the object after obj. Returns 0 if obj is last object.
TObject * First() const
Return the object in the first slot.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
virtual void AddBefore(const TObject *before, TObject *obj)
Add object in the slot before object before.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
Int_t fLowerBound
Array contents.
Int_t GetAbsLast() const
Return absolute index to last object in array.
void SetLast(Int_t last)
Set index of last object in array, effectively truncating the array.
TIterator * MakeIterator(Bool_t dir=kIterForward) const
Returns an array iterator.
virtual void Randomize(Int_t ntimes=1)
Randomize objects inside the array, i.e.
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
Int_t GetLast() const
Return index of last object in array.
TObject * Before(const TObject *obj) const
Return the object before obj. Returns 0 if obj is first object.
virtual TObject * Remove(TObject *obj)
Remove object from array.
virtual void AddFirst(TObject *obj)
Add object in the first slot of the array.
virtual void RemoveRange(Int_t idx1, Int_t idx2)
Remove objects from index idx1 to idx2 included.
TObjArray(Int_t s=TCollection::kInitCapacity, Int_t lowerBound=0)
Create an object array.
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
friend class TObjArrayIter
virtual TObject * RemoveAt(Int_t idx)
Remove object at index idx.
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 const char * GetName() const
Returns name of object.
virtual void RecursiveRemove(TObject *obj)
Recursively remove this object from a list.
R__ALWAYS_INLINE Bool_t IsOnHeap() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual Int_t Compare(const TObject *obj) const
Compare abstract method.
Sequenceable collection abstract base class.
static void QSort(TObject **a, Int_t first, Int_t last)
Sort array of TObject pointers using a quicksort algorithm.
static void * Alloc(size_t size)
Allocate a block of memory, that later can be resized using TStorage::ReAlloc().
static void * ReAlloc(void *vp, size_t size)
Reallocate (i.e.
static void Dealloc(void *ptr)
De-allocate block of memory, that was allocated via TStorage::Alloc().
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
R__EXTERN TVirtualRWMutex * gCoreMutex
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)