23 #ifndef _GEMA_DUAL_VECTOR_H_ 24 #define _GEMA_DUAL_VECTOR_H_ 44 static_assert(!QTypeInfo<T>::isComplex,
"Not a POD type");
67 const T*
iptr(
size_t index)
const 69 assert(index <
size());
79 assert(index <
size());
99 bool addValues(
size_t numAddedValues,
bool tight =
false)
102 if(numAddedValues == 0)
105 if(
size() > std::numeric_limits<size_t>::max() - numAddedValues)
107 gmWarnMsg(
GmPanicLogger(),
QObject::tr(
"Dual vector: Error adding %1 values. Vector size would surpass the maximum possible capacity.").arg(numAddedValues));
122 .arg(
_fixedSize + numAddedValues).arg(
sizeof(T)));
124 gmWarnMsg(
GmPanicLogger(),
QObject::tr(
"Dual vector: Error resizing a vector with %1 entries of %2 bytes to a vector with %3 entries.")
144 assert(oldNumValues <=
size());
219 bool addValues(
size_t numAddedValues,
bool tight =
false)
223 if(
_size > std::numeric_limits<size_t>::max() - numAddedValues)
225 gmWarnMsg(
GmPanicLogger(),
QObject::tr(
"Dual vector: Error adding %1 values. Vector size would surpass the maximum possible capacity.").arg(numAddedValues));
229 size_t nadd = numAddedValues;
241 _size += numAddedValues;
250 _size = oldNumValues;
267 assert(index + numValues <=
_size);
277 size_t fr = index + numValues;
278 size_t nr =
_size - fr;
281 for(
size_t i = 0; i < nr; i++)
GmDualVector(size_t nvalues)
The constructor initializing the "fixed" part size. The vector contents is NOT initialized.
Definition: gmDualVector.h:53
size_t size() const
Returns the vector size.
Definition: gmDualVector.h:209
const GmLogCategory & GmPanicLogger()
Returns the global "panic" logger, usually used to report memory allocation fails deep inside class s...
Definition: gmLog.cpp:700
T DataType
The stored data type.
Definition: gmDualVector.h:44
GmDualVectorR(size_t nvalues)
The constructor initializing the "fixed" part size. The vector contents is NOT initialized.
Definition: gmDualVector.h:203
int numDumpBuffers() const
Returns the number of internal buffers used by this implementation.
Definition: gmDualVector.h:173
#define S_TRACE()
Macro for run time stack tracking at release build.
Definition: gmTrace.h:44
T & operator[](size_t index)
Non-const overload for the standard indexing operator.
Definition: gmDualVector.h:90
size_t _fixedSize
The number of entries in _fixedData.
Definition: gmDualVector.h:183
QString tr(const char *sourceText, const char *disambiguation, int n)
GmPODVector< T > _growData
The variable part.
Definition: gmDualVector.h:185
Implementation of the GmPODVector template class.
void clear()
Clears all stored data returning the object to a default constructed state.
Definition: gmDualVector.h:294
const T * iptr(size_t index) const
Returns a pointer to the index data inside the vector. By the very nature of this class,...
Definition: gmDualVector.h:67
GmDualVector()
Default constructor.
Definition: gmDualVector.h:50
size_t size() const
Returns the vector size.
Definition: gmDualVector.h:59
bool addValues(size_t numAddedValues, bool tight=false)
Adds numAddedValues to the set, without any initialization. Returns true on success,...
Definition: gmDualVector.h:219
~GmDualVector()
Destructor.
Definition: gmDualVector.h:56
void restoreSize(size_t oldNumValues)
Restores the size of the set to the previous size before the last call to addValues().
Definition: gmDualVector.h:246
size_t dumpBufferSize(int i) const
Returns the size in bytes of the i'th internal buffer returned by dumpBuffer(i)
Definition: gmDualVector.h:179
size_t _size
The total number of entries in the vector. Can be less than _fixedSize if entries where removed from ...
Definition: gmDualVector.h:304
void removeValues(size_t index, size_t numValues)
Removes numValues from the set, starting from (and including) index.
Definition: gmDualVector.h:264
bool resize(ControlSize newSize, GmPODGrowT grow=Grow)
Resizes the vector to the given size using the speciefied grow policy.
Definition: gmPODVector.h:159
~GmDualVectorR()
Destructor.
Definition: gmDualVector.h:206
T * iptr(size_t index)
Non-const overload for iptr()
Definition: gmDualVector.h:77
A vector tailored for storing mesh related data for the common scenario where elements are added to t...
Definition: gmDualVector.h:41
A class very simmilar to GmDualVector with support for removing values. Removing values should be use...
Definition: gmDualVector.h:196
size_t usedMemory() const
Returns an estimative of the memory used by the data set in bytes.
Definition: gmDualVector.h:170
void remove(ControlSize index, ControlSize numValues)
Removes numValues entries from the vector starting at index.
Definition: gmPODVector.h:139
T * _fixedData
The fixed part of the dual vector with _fixedSize entries.
Definition: gmDualVector.h:182
GmDualVectorR()
Default constructor.
Definition: gmDualVector.h:200
ControlSize capacity() const
Returns the vector allocated capacity.
Definition: gmPODVector.h:106
char * dumpBuffer(int i) const
Returns the i'th internal buffer, i from 0 to numDumpBuffers()-1.
Definition: gmDualVector.h:176
const T * data() const
Returns a pointer to the data inside the vector.
Definition: gmPODVector.h:109
ControlSize size() const
Returns the vector size.
Definition: gmPODVector.h:103
void clear()
Clears all stored data returning the object to a default constructed state.
Definition: gmDualVector.h:156
size_t GmPODVectorTightGrow(size_t s, size_t a)
Vector growing to exactly the needed size.
Definition: gmPODVector.h:72
void clear()
Clears the vector deallocating used memory.
Definition: gmPODVector.h:229
bool addValues(size_t numAddedValues, bool tight=false)
Adds numAddedValues to the set, without any initialization. Returns true on success,...
Definition: gmDualVector.h:99
void restoreSize(size_t oldNumValues)
Restores the size of the set to the previous size before the last call to addValues().
Definition: gmDualVector.h:141
const T & operator[](size_t index) const
Standard indexing operator.
Definition: gmDualVector.h:87