// @(#)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" //______________________________________________________________________________ // // 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); //______________________________________________________________________________ void TEveChunkManager::ReleaseChunks() { // Release all memory chunks. 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); } /******************************************************************************/ //______________________________________________________________________________ Char_t* TEveChunkManager::NewChunk() { // Allocate a new memory chunk and register it. fChunks.push_back(new TArrayC(fS*fN)); ++fVecSize; fCapacity += fN; return fChunks.back()->fArray; } /******************************************************************************/ //______________________________________________________________________________ Bool_t TEveChunkManager::iterator::next() { // Go to next atom. 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; } } }