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