Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TSeqCollection.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/cont:$Id$
0002 // Author: Fons Rademakers   04/08/95
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TSeqCollection
0013 #define ROOT_TSeqCollection
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TSeqCollection                                                       //
0019 //                                                                      //
0020 // Sequenceable collection abstract base class. TSeqCollection's have   //
0021 // an ordering relation, i.e. there is a first and last element.        //
0022 //                                                                      //
0023 //////////////////////////////////////////////////////////////////////////
0024 
0025 #include "TCollection.h"
0026 
0027 
0028 class TSeqCollection : public TCollection {
0029 
0030 protected:
0031    Bool_t            fSorted;    // true if collection has been sorted
0032 
0033    TSeqCollection() : fSorted(kFALSE) { }
0034    virtual void      Changed() { fSorted = kFALSE; }
0035 
0036 public:
0037    virtual           ~TSeqCollection() { }
0038    void              Add(TObject *obj) override { AddLast(obj); }
0039    virtual void      AddFirst(TObject *obj) = 0;
0040    virtual void      AddLast(TObject *obj) = 0;
0041    virtual void      AddAt(TObject *obj, Int_t idx) = 0;
0042    virtual void      AddAfter(const TObject *after, TObject *obj) = 0;
0043    virtual void      AddBefore(const TObject *before, TObject *obj) = 0;
0044    virtual void      RemoveFirst() { Remove(First()); }
0045    virtual void      RemoveLast() { Remove(Last()); }
0046    virtual TObject  *RemoveAt(Int_t idx) { return Remove(At(idx)); }
0047    virtual void      RemoveAfter(TObject *after) { Remove(After(after)); }
0048    virtual void      RemoveBefore(TObject *before) { Remove(Before(before)); }
0049 
0050    virtual TObject  *At(Int_t idx) const = 0;
0051    virtual TObject  *Before(const TObject *obj) const = 0;
0052    virtual TObject  *After(const TObject *obj) const = 0;
0053    virtual TObject  *First() const = 0;
0054    virtual TObject  *Last() const = 0;
0055    Int_t             LastIndex() const { return GetSize() - 1; }
0056    virtual Int_t     GetLast() const;
0057    virtual Int_t     IndexOf(const TObject *obj) const;
0058    virtual Bool_t    IsSorted() const { return fSorted; }
0059    void              UnSort() { fSorted = kFALSE; }
0060    Long64_t          Merge(TCollection *list);
0061 
0062    static Int_t       ObjCompare(TObject *a, TObject *b);
0063    static void        QSort(TObject **a, Int_t first, Int_t last);
0064    static inline void QSort(TObject **a, TObject **b, Int_t first, Int_t last) { QSort(a, 1, &b, first, last); }
0065    static void        QSort(TObject **a, Int_t nBs, TObject ***b, Int_t first, Int_t last);
0066 
0067    ClassDefOverride(TSeqCollection,0)  //Sequenceable collection ABC
0068 };
0069 
0070 #endif