23 #ifndef _GEMA_SINGLE_VECTOR_H_ 24 #define _GEMA_SINGLE_VECTOR_H_ 39 static_assert(!QTypeInfo<T>::isComplex,
"Not a POD type");
54 const T*
iptr(
size_t index)
const { assert(index < _v.
size());
return _v.
data() + index; }
57 T*
iptr(
size_t index) { assert(index < _v.
size());
return _v.
data() + index; }
72 bool addValues(
size_t numAddedValues,
bool tight =
false)
74 if(_v.
size() > std::numeric_limits<size_t>::max() - numAddedValues)
76 gmWarnMsg(
GmPanicLogger(),
QObject::tr(
"Single vector: Error adding values. Vector size would surpass the maximum possible capacity."));
80 if(tight || !_v.
size())
89 assert(oldNumValues <= _v.
size());
110 char*
dumpBuffer(
int i)
const { Q_UNUSED(i); assert(i == 0);
return (
char*)_v.
data(); }
const GmLogCategory & GmPanicLogger()
Returns the global "panic" logger, usually used to report memory allocation fails deep inside class s...
Definition: gmLog.cpp:700
const T * iptr(size_t index) const
Returns a pointer to the index data inside the vector.
Definition: gmSingleVector.h:54
A class with the same API as GmDualVector storing a single vector. No query "if" overhead....
Definition: gmSingleVector.h:36
bool addValues(size_t numAddedValues, bool tight=false)
Adds numAddedValues to the set, without any initialization. Returns true on success,...
Definition: gmSingleVector.h:72
size_t dumpBufferSize(int i) const
Returns the size in bytes of the i'th internal buffer returned by dumpBuffer(i)
Definition: gmSingleVector.h:113
T * iptr(size_t index)
Non-const overload for iptr()
Definition: gmSingleVector.h:57
QString tr(const char *sourceText, const char *disambiguation, int n)
const T & operator[](size_t index) const
Standard indexing operator.
Definition: gmSingleVector.h:60
Implementation of the GmPODVector template class.
T & operator[](size_t index)
Non-const overload for the standard indexing operator.
Definition: gmSingleVector.h:63
void restoreSize(size_t oldNumValues)
Restores the size of the set to the previous size before the last call to addValues().
Definition: gmSingleVector.h:87
size_t usedMemory() const
Returns an estimative of the memory used by the data set in bytes.
Definition: gmSingleVector.h:104
void clear()
Clears all stored data returning the object to a default constructed state.
Definition: gmSingleVector.h:97
GmSingleVector()
Default constructor.
Definition: gmSingleVector.h:45
char * dumpBuffer(int i) const
Returns the i'th internal buffer, i from 0 to numDumpBuffers()-1.
Definition: gmSingleVector.h:110
bool resize(ControlSize newSize, GmPODGrowT grow=Grow)
Resizes the vector to the given size using the speciefied grow policy.
Definition: gmPODVector.h:159
void removeValues(size_t index, size_t numValues)
Removes numValues from the set, starting from (and including) index.
Definition: gmSingleVector.h:94
size_t size() const
Returns the vector size.
Definition: gmSingleVector.h:51
GmSingleVector(size_t nvalues)
The constructor initializing the vector with the given size. The vector contents is NOT initialized.
Definition: gmSingleVector.h:48
T DataType
The stored data type.
Definition: gmSingleVector.h:39
void remove(ControlSize index, ControlSize numValues)
Removes numValues entries from the vector starting at index.
Definition: gmPODVector.h:139
ControlSize capacity() const
Returns the vector allocated capacity.
Definition: gmPODVector.h:106
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
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
int numDumpBuffers() const
Returns the number of internal buffers used by this implementation.
Definition: gmSingleVector.h:107