15 /**************************************************************************/
17 /**************************************************************************/
22 VoidCPlex(const VoidCPlex&); // Not implemented
23 VoidCPlex& operator=(const VoidCPlex&); // Not implemented
26 Int_t fS; // Size of atom
27 Int_t fN; // Number of atoms in a chunk
29 Int_t fSize; // Size of container, number of atoms
30 Int_t fVecSize; // Number of allocated chunks
31 Int_t fCapacity; // Available capacity within the chunks
33 std::vector<TArrayC*> fChunks; // Memory blocks
39 VoidCPlex(Int_t atom_size, Int_t chunk_size);
42 void Reset(Int_t atom_size, Int_t chunk_size);
45 Int_t S() const { return fS; }
46 Int_t N() const { return fN; }
48 Int_t Size() const { return fSize; }
49 Int_t VecSize() const { return fVecSize; }
50 Int_t Capacity() const { return fCapacity; }
52 Char_t* Atom(Int_t idx) const { return fChunks[idx/fN]->fArray + idx%fN*fS; }
53 Char_t* Chunk(Int_t chk) const { return fChunks[chk]->fArray; }
54 Int_t NAtoms(Int_t chk) const { return (chk < fVecSize-1) ? fN : (fSize-1)%fN + 1; }
70 iterator(VoidCPlex* p) :
71 fPlex(p), fCurrent(0), fAtomIndex(-1), fNextChunk(0), fAtomsToGo(0) {}
72 iterator(VoidCPlex& p) :
73 fPlex(&p), fCurrent(0), fAtomIndex(-1), fNextChunk(0), fAtomsToGo(0) {}
76 void reset() { fCurrent = 0; fNextChunk = fAtomsToGo = 0; }
78 Char_t* operator()() { return fCurrent; }
79 Char_t* operator*() { return fCurrent; }
80 Int_t index() { return fAtomIndex; }
84 ClassDef(VoidCPlex, 1)
87 inline Char_t* VoidCPlex::NewAtom()
89 Char_t *a = (fSize >= fCapacity) ? NewChunk() : Atom(fSize);
94 inline Bool_t VoidCPlex::iterator::next()
96 if (fAtomsToGo <= 0) {
97 if (fNextChunk < fPlex->fVecSize) {
98 fCurrent = fPlex->Chunk(fNextChunk);
99 fAtomsToGo = fPlex->NAtoms(fNextChunk);
105 fCurrent += fPlex->fS;
113 /**************************************************************************/
115 /**************************************************************************/
118 class CPlex : public VoidCPlex
121 CPlex(const CPlex&); // Not implemented
122 CPlex& operator=(const CPlex&); // Not implemented
125 CPlex() : VoidCPlex() {}
126 CPlex(Int_t chunk_size) : VoidCPlex(sizeof(T), chunk_size) {}
129 void Reset(Int_t chunk_size) { Reset(sizeof(T), chunk_size); }
131 T* At(Int_t idx) { return reinterpret_cast<T*>(Atom(idx)); }
132 T& Ref(Int_t idx) { return *At(idx); }