Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

TSeqCollection.h

Go to the documentation of this file.
00001 // @(#)root/cont:$Name:  $:$Id: TSeqCollection.h,v 1.5 2001/01/09 18:33:59 rdm Exp $
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 
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 //                                                                      //
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() { }
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(TObject *after, TObject *obj) = 0;
00045    virtual void      AddBefore(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(TObject *obj) const = 0;
00054    virtual TObject  *After(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 
00062    static Int_t      ObjCompare(TObject *a, TObject *b);
00063    static void       QSort(TObject **a, Int_t first, Int_t last);
00064    static void       QSort(TObject **a, TObject **b, Int_t first, Int_t last);
00065 
00066    ClassDef(TSeqCollection,0)  //Sequenceable collection ABC
00067 };
00068 
00069 #endif

Generated on Thu Dec 18 14:52:23 2003 for ROOT by doxygen1.2.16