AliPhysics  8bb951a (8bb951a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalIterableContainer.h
Go to the documentation of this file.
1 #ifndef ALIEMCALITERABLECONTAINER_H
2 #define ALIEMCALITERABLECONTAINER_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice */
5 
6 #include <iterator>
7 #include <TArrayI.h>
8 #include <TObject.h>
9 
10 class AliEmcalContainer;
11 
51 class AliEmcalIterableContainer : public TObject {
52 public:
70  class iterator : public std::iterator<std::bidirectional_iterator_tag,
71  TObject,std::ptrdiff_t,
72  TObject **, TObject *>{
73  public:
74  iterator(const AliEmcalIterableContainer *cont, int currentpos, bool forward = true);
75  iterator(const iterator &ref);
76  iterator &operator=(const iterator &ref);
77  virtual ~iterator(){}
78 
79  bool operator!=(const iterator &ref) const;
80 
82  iterator operator++(int);
84  iterator operator--(int);
85 
86  TObject *operator*() const;
87 
88  private:
89  iterator();
90 
92  int fCurrent;
93  bool fForward;
94  };
95 
97  AliEmcalIterableContainer(const AliEmcalContainer *cont, bool useAccept);
100 
105 
106  TObject *operator[](int index) const;
107 
112  operator int() const { return GetEntries(); }
113 
118  const AliEmcalContainer *GetContainer() const { return fkContainer; }
119 
120  int GetEntries() const;
121 
127  iterator begin() const { return iterator(this, 0, true); }
128 
134  iterator end() const { return iterator(this, GetEntries(), true); }
135 
141  iterator rbegin() const { return iterator(this, GetEntries()-1, false); }
142 
148  iterator rend() const { return iterator(this, -1, false); }
149 
150 protected:
151  void BuildAcceptIndices();
152 
153 private:
155  TArrayI fAcceptIndices;
156  Bool_t fUseAccepted;
157 
159  ClassDef(AliEmcalIterableContainer, 1);
161 };
162 
163 #endif /* ALIEMCALITERABLECONTAINER_H */
const AliEmcalContainer * fkContainer
Container to be iterated over.
TObject * operator[](int index) const
bool fForward
use forward or backward direction
Base class for container structures within the EMCAL framework.
bool operator!=(const iterator &ref) const
Container implementing iterable functionality of the EMCAL containers.
TArrayI fAcceptIndices
Array of accepted indices.
Bool_t fUseAccepted
Switch between accepted and all objects.
bidirectional stl iterator over the EMCAL iterable container
int fCurrent
current index in the container
AliEmcalIterableContainer & operator=(const AliEmcalIterableContainer &cont)
const AliEmcalIterableContainer * fkData
container with data
const AliEmcalContainer * GetContainer() const
iterator & operator=(const iterator &ref)