ROOT logo
// @(#)root/cont:$Id$
// Author: Fons Rademakers   04/08/95

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TSeqCollection
#define ROOT_TSeqCollection


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TSeqCollection                                                       //
//                                                                      //
// Sequenceable collection abstract base class. TSeqCollection's have   //
// an ordering relation, i.e. there is a first and last element.        //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TCollection
#include "TCollection.h"
#endif


class TSeqCollection : public TCollection {

protected:
   Bool_t            fSorted;    // true if collection has been sorted

   TSeqCollection() : fSorted(kFALSE) { }
   virtual void      Changed() { fSorted = kFALSE; }

public:
   virtual           ~TSeqCollection() { }
   virtual void      Add(TObject *obj) { AddLast(obj); }
   virtual void      AddFirst(TObject *obj) = 0;
   virtual void      AddLast(TObject *obj) = 0;
   virtual void      AddAt(TObject *obj, Int_t idx) = 0;
   virtual void      AddAfter(const TObject *after, TObject *obj) = 0;
   virtual void      AddBefore(const TObject *before, TObject *obj) = 0;
   virtual void      RemoveFirst() { Remove(First()); }
   virtual void      RemoveLast() { Remove(Last()); }
   virtual TObject  *RemoveAt(Int_t idx) { return Remove(At(idx)); }
   virtual void      RemoveAfter(TObject *after) { Remove(After(after)); }
   virtual void      RemoveBefore(TObject *before) { Remove(Before(before)); }

   virtual TObject  *At(Int_t idx) const = 0;
   virtual TObject  *Before(const TObject *obj) const = 0;
   virtual TObject  *After(const TObject *obj) const = 0;
   virtual TObject  *First() const = 0;
   virtual TObject  *Last() const = 0;
   Int_t             LastIndex() const { return GetSize() - 1; }
   virtual Int_t     GetLast() const;
   virtual Int_t     IndexOf(const TObject *obj) const;
   virtual Bool_t    IsSorted() const { return fSorted; }
   void              UnSort() { fSorted = kFALSE; }
   Long64_t          Merge(TCollection *list);

   static Int_t       ObjCompare(TObject *a, TObject *b);
   static void        QSort(TObject **a, Int_t first, Int_t last);
   static inline void QSort(TObject **a, TObject **b, Int_t first, Int_t last) { QSort(a, 1, &b, first, last); }
   static void        QSort(TObject **a, Int_t nBs, TObject ***b, Int_t first, Int_t last);

   ClassDef(TSeqCollection,0)  //Sequenceable collection ABC
};

#endif
 TSeqCollection.h:1
 TSeqCollection.h:2
 TSeqCollection.h:3
 TSeqCollection.h:4
 TSeqCollection.h:5
 TSeqCollection.h:6
 TSeqCollection.h:7
 TSeqCollection.h:8
 TSeqCollection.h:9
 TSeqCollection.h:10
 TSeqCollection.h:11
 TSeqCollection.h:12
 TSeqCollection.h:13
 TSeqCollection.h:14
 TSeqCollection.h:15
 TSeqCollection.h:16
 TSeqCollection.h:17
 TSeqCollection.h:18
 TSeqCollection.h:19
 TSeqCollection.h:20
 TSeqCollection.h:21
 TSeqCollection.h:22
 TSeqCollection.h:23
 TSeqCollection.h:24
 TSeqCollection.h:25
 TSeqCollection.h:26
 TSeqCollection.h:27
 TSeqCollection.h:28
 TSeqCollection.h:29
 TSeqCollection.h:30
 TSeqCollection.h:31
 TSeqCollection.h:32
 TSeqCollection.h:33
 TSeqCollection.h:34
 TSeqCollection.h:35
 TSeqCollection.h:36
 TSeqCollection.h:37
 TSeqCollection.h:38
 TSeqCollection.h:39
 TSeqCollection.h:40
 TSeqCollection.h:41
 TSeqCollection.h:42
 TSeqCollection.h:43
 TSeqCollection.h:44
 TSeqCollection.h:45
 TSeqCollection.h:46
 TSeqCollection.h:47
 TSeqCollection.h:48
 TSeqCollection.h:49
 TSeqCollection.h:50
 TSeqCollection.h:51
 TSeqCollection.h:52
 TSeqCollection.h:53
 TSeqCollection.h:54
 TSeqCollection.h:55
 TSeqCollection.h:56
 TSeqCollection.h:57
 TSeqCollection.h:58
 TSeqCollection.h:59
 TSeqCollection.h:60
 TSeqCollection.h:61
 TSeqCollection.h:62
 TSeqCollection.h:63
 TSeqCollection.h:64
 TSeqCollection.h:65
 TSeqCollection.h:66
 TSeqCollection.h:67
 TSeqCollection.h:68
 TSeqCollection.h:69
 TSeqCollection.h:70
 TSeqCollection.h:71
 TSeqCollection.h:72