7 //______________________________________________________________________
10 // A group of containers with chunked memory allocation.
14 //______________________________________________________________________
17 // Non-structured (Void) Complete Plex.
18 // Allocation chunk can accommodate fN atoms of byte-size fS each.
19 // The chunks themselves are TArrayCs and are stored in a std::vector<TArrayC*>.
20 // Holes in the structure are not supported, neither is removal of atoms.
21 // The structure can be Refit() to occupy a single contiguous array.
24 void VoidCPlex::ReleaseChunks()
26 for (Int_t i=0; i<fVecSize; ++i)
31 VoidCPlex::VoidCPlex() :
33 fSize(0), fVecSize(0), fCapacity(0)
36 VoidCPlex::VoidCPlex(Int_t atom_size, Int_t chunk_size) :
37 fS(atom_size), fN(chunk_size),
38 fSize(0), fVecSize(0), fCapacity(0)
41 VoidCPlex::~VoidCPlex()
46 /**************************************************************************/
48 void VoidCPlex::Reset(Int_t atom_size, Int_t chunk_size)
53 fSize = fVecSize = fCapacity = 0;
56 void VoidCPlex::Refit()
58 if (fSize == 0 || (fVecSize == 1 && fSize == fCapacity))
61 TArrayC* one = new TArrayC(fS*fSize);
62 Char_t* pos = one->fArray;
63 for (Int_t i=0; i<fVecSize; ++i)
65 Int_t size = fS * NAtoms(i);
66 memcpy(pos, fChunks[i]->fArray, size);
70 fN = fCapacity = fSize;
72 fChunks.push_back(one);
75 /**************************************************************************/
77 Char_t* VoidCPlex::NewChunk()
79 fChunks.push_back(new TArrayC(fS*fN));
82 return fChunks.back()->fArray;
85 /**************************************************************************/
86 /**************************************************************************/