Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSeqCollection.h
Go to the documentation of this file.
1// @(#)root/cont:$Id$
2// Author: Fons Rademakers 04/08/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TSeqCollection
13#define ROOT_TSeqCollection
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TSeqCollection //
19// //
20// Sequenceable collection abstract base class. TSeqCollection's have //
21// an ordering relation, i.e. there is a first and last element. //
22// //
23//////////////////////////////////////////////////////////////////////////
24
25#include "TCollection.h"
26
27
29
30protected:
31 Bool_t fSorted; // true if collection has been sorted
32
34 virtual void Changed() { fSorted = kFALSE; }
35
36public:
37 virtual ~TSeqCollection() { }
38 void Add(TObject *obj) override { AddLast(obj); }
39 void Add(TObject *obj, Option_t *opt) override { AddLast(obj, opt); }
40 virtual void AddFirst(TObject *obj) = 0;
41 virtual void AddFirst(TObject */*obj*/, Option_t */*opt*/) { AbstractMethod("AddFirst"); }; // not = 0, to not break user scripts
42 virtual void AddLast(TObject *obj) = 0;
43 virtual void AddLast(TObject */*obj*/, Option_t */*opt*/) { AbstractMethod("AddLast"); }; // not = 0, to not break user scripts
44 virtual void AddAt(TObject *obj, Int_t idx) = 0;
45 virtual void AddAt(TObject */*obj*/, Int_t /*idx*/, Option_t */*opt*/) { AbstractMethod("AddAt"); }; // not = 0, to not break user scripts
46 virtual void AddAfter(const TObject *after, TObject *obj) = 0;
47 virtual void AddAfter(const TObject */*after*/, TObject */*obj*/, Option_t */*opt*/) { AbstractMethod("AddAfter"); }; // not = 0, to not break user scripts
48 virtual void AddBefore(const TObject *before, TObject *obj) = 0;
49 virtual void AddBefore(const TObject */*before*/, TObject */*obj*/, Option_t */*opt*/) { AbstractMethod("AddABefore"); }; // not = 0, to not break user scripts
50 virtual void RemoveFirst() { Remove(First()); }
51 virtual void RemoveLast() { Remove(Last()); }
52 virtual TObject *RemoveAt(Int_t idx) { return Remove(At(idx)); }
53 virtual void RemoveAfter(TObject *after) { Remove(After(after)); }
55
56 virtual TObject *At(Int_t idx) const = 0;
57 virtual TObject *Before(const TObject *obj) const = 0;
58 virtual TObject *After(const TObject *obj) const = 0;
59 virtual TObject *First() const = 0;
60 virtual TObject *Last() const = 0;
61 Int_t LastIndex() const { return GetSize() - 1; }
62 virtual Int_t GetLast() const;
63 virtual Int_t IndexOf(const TObject *obj) const;
64 virtual Bool_t IsSorted() const { return fSorted; }
65 void UnSort() { fSorted = kFALSE; }
67
68 static Int_t ObjCompare(TObject *a, TObject *b);
69 static void QSort(TObject **a, Int_t first, Int_t last);
70 static inline void QSort(TObject **a, TObject **b, Int_t first, Int_t last) { QSort(a, 1, &b, first, last); }
71 static void QSort(TObject **a, Int_t nBs, TObject ***b, Int_t first, Int_t last);
72
73 ClassDefOverride(TSeqCollection,0) //Sequenceable collection ABC
74};
75
76#endif
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
Collection abstract base class.
Definition TCollection.h:65
virtual TObject * Remove(TObject *obj)=0
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Mother of all ROOT objects.
Definition TObject.h:41
void AbstractMethod(const char *method) const
Call this function within a function that you don't want to define as purely virtual,...
Definition TObject.cxx:1139
Sequenceable collection abstract base class.
Int_t LastIndex() const
virtual TObject * After(const TObject *obj) const =0
virtual void RemoveLast()
virtual ~TSeqCollection()
virtual TObject * RemoveAt(Int_t idx)
static void QSort(TObject **a, TObject **b, Int_t first, Int_t last)
virtual void RemoveBefore(TObject *before)
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
virtual void AddLast(TObject *obj)=0
virtual void AddBefore(const TObject *before, TObject *obj)=0
virtual void AddAt(TObject *, Int_t, Option_t *)
virtual void RemoveFirst()
virtual TObject * Before(const TObject *obj) const =0
virtual void AddLast(TObject *, Option_t *)
virtual void AddAt(TObject *obj, Int_t idx)=0
virtual TObject * Last() const =0
void Add(TObject *obj, Option_t *opt) override
virtual void AddAfter(const TObject *after, TObject *obj)=0
virtual void RemoveAfter(TObject *after)
virtual Bool_t IsSorted() const
virtual void Changed()
static void QSort(TObject **a, Int_t first, Int_t last)
Sort array of TObject pointers using a quicksort algorithm.
virtual TObject * First() const =0
virtual void AddBefore(const TObject *, TObject *, Option_t *)
Long64_t Merge(TCollection *list)
Merge this collection with all collections coming in the input list.
virtual Int_t GetLast() const
Returns index of last object in collection.
virtual void AddAfter(const TObject *, TObject *, Option_t *)
static Int_t ObjCompare(TObject *a, TObject *b)
Compare to objects in the collection. Use member Compare() of object a.
virtual TObject * At(Int_t idx) const =0
virtual void AddFirst(TObject *, Option_t *)
virtual void AddFirst(TObject *obj)=0
void Add(TObject *obj) override