// @(#)root/eve:$Id$ // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 /************************************************************************* * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #include "TEveChunkManager.h" /** \class TEveChunkManager \ingroup TEve Vector-like container with chunked memory allocation. Allocation chunk can accommodate fN atoms of byte-size fS each. The chunks themselves are TArrayCs and are stored in a std::vector. Holes in the structure are not supported, neither is removal of atoms. The structure can be Refit() to occupy a single contiguous array. */ ClassImp(TEveChunkManager); ClassImp(TEveChunkManager::iterator); //////////////////////////////////////////////////////////////////////////////// /// Release all memory chunks. void TEveChunkManager::ReleaseChunks() { for (Int_t i=0; ifArray; for (Int_t i=0; ifArray, size); pos += size; } ReleaseChunks(); fN = fCapacity = fSize; fVecSize = 1; fChunks.push_back(one); } //////////////////////////////////////////////////////////////////////////////// /// Allocate a new memory chunk and register it. Char_t* TEveChunkManager::NewChunk() { fChunks.push_back(new TArrayC(fS*fN)); ++fVecSize; fCapacity += fN; return fChunks.back()->fArray; } //////////////////////////////////////////////////////////////////////////////// /// Go to next atom. Bool_t TEveChunkManager::iterator::next() { if (fSelection == 0) { if (fAtomsToGo <= 0) { if (fNextChunk < fPlex->VecSize()) { fCurrent = fPlex->Chunk(fNextChunk); fAtomsToGo = fPlex->NAtoms(fNextChunk); ++fNextChunk; } else { return kFALSE; } } else { fCurrent += fPlex->S(); } ++fAtomIndex; --fAtomsToGo; return kTRUE; } else { if (fAtomIndex == -1) fSelectionIterator = fSelection->begin(); else ++fSelectionIterator; if (fSelectionIterator != fSelection->end()) { fAtomIndex = *fSelectionIterator; fCurrent = fPlex->Atom(fAtomIndex); return kTRUE; } else { return kFALSE; } } }