Logo ROOT  
Reference Guide
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 
28 class TSeqCollection : public TCollection {
29 
30 protected:
31  Bool_t fSorted; // true if collection has been sorted
32 
34  virtual void Changed() { fSorted = kFALSE; }
35 
36 public:
37  virtual ~TSeqCollection() { }
38  virtual void Add(TObject *obj) { AddLast(obj); }
39  virtual void AddFirst(TObject *obj) = 0;
40  virtual void AddLast(TObject *obj) = 0;
41  virtual void AddAt(TObject *obj, Int_t idx) = 0;
42  virtual void AddAfter(const TObject *after, TObject *obj) = 0;
43  virtual void AddBefore(const TObject *before, TObject *obj) = 0;
44  virtual void RemoveFirst() { Remove(First()); }
45  virtual void RemoveLast() { Remove(Last()); }
46  virtual TObject *RemoveAt(Int_t idx) { return Remove(At(idx)); }
47  virtual void RemoveAfter(TObject *after) { Remove(After(after)); }
48  virtual void RemoveBefore(TObject *before) { Remove(Before(before)); }
49 
50  virtual TObject *At(Int_t idx) const = 0;
51  virtual TObject *Before(const TObject *obj) const = 0;
52  virtual TObject *After(const TObject *obj) const = 0;
53  virtual TObject *First() const = 0;
54  virtual TObject *Last() const = 0;
55  Int_t LastIndex() const { return GetSize() - 1; }
56  virtual Int_t GetLast() const;
57  virtual Int_t IndexOf(const TObject *obj) const;
58  virtual Bool_t IsSorted() const { return fSorted; }
59  void UnSort() { fSorted = kFALSE; }
60  Long64_t Merge(TCollection *list);
61 
62  static Int_t ObjCompare(TObject *a, TObject *b);
63  static void QSort(TObject **a, Int_t first, Int_t last);
64  static inline void QSort(TObject **a, TObject **b, Int_t first, Int_t last) { QSort(a, 1, &b, first, last); }
65  static void QSort(TObject **a, Int_t nBs, TObject ***b, Int_t first, Int_t last);
66 
67  ClassDef(TSeqCollection,0) //Sequenceable collection ABC
68 };
69 
70 #endif
first
Definition: first.py:1
TSeqCollection::Add
virtual void Add(TObject *obj)
Definition: TSeqCollection.h:38
TSeqCollection::QSort
static void QSort(TObject **a, Int_t first, Int_t last)
Sort array of TObject pointers using a quicksort algorithm.
Definition: TSeqCollection.cxx:70
TSeqCollection::UnSort
void UnSort()
Definition: TSeqCollection.h:59
TSeqCollection::AddLast
virtual void AddLast(TObject *obj)=0
TCollection.h
TCollection::Remove
virtual TObject * Remove(TObject *obj)=0
TSeqCollection::AddFirst
virtual void AddFirst(TObject *obj)=0
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TSeqCollection::RemoveLast
virtual void RemoveLast()
Definition: TSeqCollection.h:45
Int_t
int Int_t
Definition: RtypesCore.h:45
TSeqCollection::TSeqCollection
TSeqCollection()
Definition: TSeqCollection.h:33
TSeqCollection::LastIndex
Int_t LastIndex() const
Definition: TSeqCollection.h:55
TSeqCollection::~TSeqCollection
virtual ~TSeqCollection()
Definition: TSeqCollection.h:37
b
#define b(i)
Definition: RSha256.hxx:100
TSeqCollection::QSort
static void QSort(TObject **a, TObject **b, Int_t first, Int_t last)
Definition: TSeqCollection.h:64
bool
TSeqCollection::First
virtual TObject * First() const =0
TSeqCollection::IndexOf
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
Definition: TSeqCollection.cxx:30
TSeqCollection::fSorted
Bool_t fSorted
Definition: TSeqCollection.h:31
TSeqCollection::Changed
virtual void Changed()
Definition: TSeqCollection.h:34
TSeqCollection::Merge
Long64_t Merge(TCollection *list)
Merge this collection with all collections coming in the input list.
Definition: TSeqCollection.cxx:185
a
auto * a
Definition: textangle.C:12
TSeqCollection::RemoveFirst
virtual void RemoveFirst()
Definition: TSeqCollection.h:44
TSeqCollection::AddAfter
virtual void AddAfter(const TObject *after, TObject *obj)=0
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TSeqCollection::After
virtual TObject * After(const TObject *obj) const =0
TSeqCollection
Sequenceable collection abstract base class.
Definition: TSeqCollection.h:28
TSeqCollection::RemoveBefore
virtual void RemoveBefore(TObject *before)
Definition: TSeqCollection.h:48
TCollection::GetSize
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
TSeqCollection::IsSorted
virtual Bool_t IsSorted() const
Definition: TSeqCollection.h:58
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TSeqCollection::Before
virtual TObject * Before(const TObject *obj) const =0
TCollection
Collection abstract base class.
Definition: TCollection.h:63
TSeqCollection::RemoveAfter
virtual void RemoveAfter(TObject *after)
Definition: TSeqCollection.h:47
TSeqCollection::GetLast
virtual Int_t GetLast() const
Returns index of last object in collection.
Definition: TSeqCollection.cxx:47
TSeqCollection::AddAt
virtual void AddAt(TObject *obj, Int_t idx)=0
TSeqCollection::Last
virtual TObject * Last() const =0
TSeqCollection::AddBefore
virtual void AddBefore(const TObject *before, TObject *obj)=0
TSeqCollection::RemoveAt
virtual TObject * RemoveAt(Int_t idx)
Definition: TSeqCollection.h:46
TSeqCollection::At
virtual TObject * At(Int_t idx) const =0
TSeqCollection::ObjCompare
static Int_t ObjCompare(TObject *a, TObject *b)
Compare to objects in the collection. Use member Compare() of object a.
Definition: TSeqCollection.cxx:56
int