TSeqCollection.h

Go to the documentation of this file.
00001 // @(#)root/cont:$Id: TSeqCollection.h 33807 2010-06-10 07:23:32Z brun $
00002 // Author: Fons Rademakers   04/08/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TSeqCollection
00013 #define ROOT_TSeqCollection
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TSeqCollection                                                       //
00019 //                                                                      //
00020 // Sequenceable collection abstract base class. TSeqCollection's have   //
00021 // an ordering relation, i.e. there is a first and last element.        //
00022 //                                                                      //
00023 //////////////////////////////////////////////////////////////////////////
00024 
00025 #ifndef ROOT_TCollection
00026 #include "TCollection.h"
00027 #endif
00028 
00029 
00030 class TSeqCollection : public TCollection {
00031 
00032 protected:
00033    Bool_t            fSorted;    // true if collection has been sorted
00034 
00035    TSeqCollection() : fSorted(kFALSE) { }
00036    virtual void      Changed() { fSorted = kFALSE; }
00037 
00038 public:
00039    virtual           ~TSeqCollection() { }
00040    virtual void      Add(TObject *obj) { AddLast(obj); }
00041    virtual void      AddFirst(TObject *obj) = 0;
00042    virtual void      AddLast(TObject *obj) = 0;
00043    virtual void      AddAt(TObject *obj, Int_t idx) = 0;
00044    virtual void      AddAfter(const TObject *after, TObject *obj) = 0;
00045    virtual void      AddBefore(const TObject *before, TObject *obj) = 0;
00046    virtual void      RemoveFirst() { Remove(First()); }
00047    virtual void      RemoveLast() { Remove(Last()); }
00048    virtual TObject  *RemoveAt(Int_t idx) { return Remove(At(idx)); }
00049    virtual void      RemoveAfter(TObject *after) { Remove(After(after)); }
00050    virtual void      RemoveBefore(TObject *before) { Remove(Before(before)); }
00051 
00052    virtual TObject  *At(Int_t idx) const = 0;
00053    virtual TObject  *Before(const TObject *obj) const = 0;
00054    virtual TObject  *After(const TObject *obj) const = 0;
00055    virtual TObject  *First() const = 0;
00056    virtual TObject  *Last() const = 0;
00057    Int_t             LastIndex() const { return GetSize() - 1; }
00058    virtual Int_t     IndexOf(const TObject *obj) const;
00059    virtual Bool_t    IsSorted() const { return fSorted; }
00060    void              UnSort() { fSorted = kFALSE; }
00061    Long64_t          Merge(TCollection *list);
00062 
00063    static Int_t       ObjCompare(TObject *a, TObject *b);
00064    static void        QSort(TObject **a, Int_t first, Int_t last);
00065    static inline void QSort(TObject **a, TObject **b, Int_t first, Int_t last) { QSort(a, 1, &b, first, last); }
00066    static void        QSort(TObject **a, Int_t nBs, TObject ***b, Int_t first, Int_t last);
00067 
00068    ClassDef(TSeqCollection,0)  //Sequenceable collection ABC
00069 };
00070 
00071 #endif

Generated on Tue Jul 5 14:11:28 2011 for ROOT_528-00b_version by  doxygen 1.5.1