25 template <
class T,
int EXP = 10 >
112 void Resize(
const int newsize);
122 for (c = 0; c < nc; c++){
126 buf.
Read(&compactScheme, 1);
135 for (c = 0; c < nc; c++){
164 template<
class T,
int EXP>
170 for (
int i = 0; i < numberofchunks; i++) {
177 template<
class T,
int EXP >
183 template<
class T,
int EXP >
187 int chunk = index >> EXP;
198 template<
class T,
int EXP >
202 PZError <<
"TPZAdmChunkVector::SetFree. Bad parameter index." << std::endl;
208 int chunk = index >> EXP;
221 template<
class T,
int EXP >
231 int chunksize = 1 << EXP;
234 int i = nchunksused - 1;
235 int maxfree = this->
NElements()-((nchunksused - 1) << EXP);
237 if (i >= 0 && this->
fVec[i] &&
fNFree[i] == maxfree) {
240 while (i >= 0 && this->
fVec[i] &&
fNFree[i] == chunksize) {
251 PZError <<
"TPZAdmChunkVector::CompactDataStructure. Bad parameter type." 257 template <
class T,
int EXP >
264 template <
class T,
int EXP>
279 template<
class T,
int EXP >
283 PZError <<
"TPZAdmChunkVector::Resize. Bad parameter newsize." << std::endl;
297 for (
int i = nchunks; i < chunksneeded; i++) {
301 if (chunksneeded > nchunks)
return;
313 int chunk = index >> EXP;
315 if (chunk == chunksneeded - 1)
316 fNFree[chunksneeded - 1]--;
323 #endif // PZADMCHUNK_H #define DEFAULTNUMBEROFCHUNKS
Default number of elements which will be allocated in the chunk vector.
int AllocateNewElement()
Makes more room for new elements.
void WriteInternal(const T &input, TPZStream &buf, int withclassid)
TPZAdmChunkVector(const TPZAdmChunkVector< T, EXP > &AdmCh)
Copy constructor.
std::underlying_type< Enumeration >::type as_integer(const Enumeration value)
int PrintFree(int i)
Print index i into the fFree vector.
int64_t NElements() const
Access method to query the number of elements of the vector.
REAL val(STATE &number)
Returns value of the variable.
Implements a chunk vector with free store administration. Utility.
void Resize(const int64_t newsize)
Increase the size of the chunk vector.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
TPZManVector< T * > fVec
Vector which points to each chunk of objects.
CompactScheme fCompactScheme
Internal variable indicating the type of compacting scheme.
void Resize(const int newsize)
Increase the size of the chunk vector.
void Push(const T object)
Pushes a copy of the object on the stack.
virtual void Write(const bool val)
int64_t NFreeElements() const
Access method to return the number of free elements.
void ReadInternal(T &output, TPZStream &buf, void *context)
An object of this class implements a vector which allocates objects by chunks. Utility.
TPZManVector< int > fNFree
Number of free elements within each chunk.
void CompactDataStructure(CompactScheme type=CompactScheme::ALWAYS)
Sets the method to compact the data structure based on the.
int ClassId() const override
Define the class id associated with the class.
void Shrink()
It reallocates storage to fit the necessary storage exactly.
TPZChunkVector< T, EXP > & operator=(const TPZChunkVector< T, EXP > &TCh)
Assignment operator, copies all elements from the object TCh.
int32_t Hash(std::string str)
virtual ~TPZAdmChunkVector()
Destructor.
T Pop()
Retrieve an object from the stack.
TPZAdmChunkVector< T, EXP > & operator=(const TPZAdmChunkVector< T, EXP > &TPZAdmCh)
Assignment operator.
Free store vector implementation in chunks.
This class implements a geometric mesh for the pz environment. Geometry.
TPZStack< int > fFree
List of indexes of freed elements.
void SetFree(int index)
Indicate an element as free.
Defines the interface for saving and reading data. Persistency.
int64_t NElements() const
Returns the number of elements of the vector.
void Read(TPZStream &buf, void *context) override
read objects from the stream
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
int ClassId() const override
Define the class id associated with the class.
#define PZError
Defines the output device to error messages and the DebugStop() function.
virtual void Read(bool &val)
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.