GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
GmDualVectorR< T > Class Template Reference

A class very simmilar to GmDualVector with support for removing values. Removing values should be used with caution. See the comments on the function. More...

#include <gmDualVector.h>

Inheritance diagram for GmDualVectorR< T >:
Collaboration diagram for GmDualVectorR< T >:

Public Member Functions

 GmDualVectorR ()
 Default constructor.
 
 GmDualVectorR (size_t nvalues)
 The constructor initializing the "fixed" part size. The vector contents is NOT initialized.
 
 ~GmDualVectorR ()
 Destructor.
 
size_t size () const
 Returns the vector size.
 
bool addValues (size_t numAddedValues, bool tight=false)
 Adds numAddedValues to the set, without any initialization. Returns true on success, false on error. On errors previous values are kept. See additional comments on the base class.
 
void restoreSize (size_t oldNumValues)
 Restores the size of the set to the previous size before the last call to addValues(). Can be called with the current size if addValues was not called.
 
void removeValues (size_t index, size_t numValues)
 Removes numValues from the set, starting from (and including) index.
 
void clear ()
 Clears all stored data returning the object to a default constructed state.
 
size_t dumpBufferSize (int i) const
 Returns the size in bytes of the i'th internal buffer returned by dumpBuffer(i)
 
- Public Member Functions inherited from GmDualVector< T >
 GmDualVector ()
 Default constructor.
 
 GmDualVector (size_t nvalues)
 The constructor initializing the "fixed" part size. The vector contents is NOT initialized.
 
 ~GmDualVector ()
 Destructor.
 
bool isDual () const
 Returns true, since this IS a Dual vector.
 
size_t size () const
 Returns the vector size.
 
const T * iptr (size_t index) const
 Returns a pointer to the index data inside the vector. By the very nature of this class, accessing following items is only safe if you know that they belong to the same internal vector. This is usually guaranteed by knowing that all data bellonging to a cell, for example, is always together in the same vector, but depends on the class usage.
 
T * iptr (size_t index)
 Non-const overload for iptr()
 
const T & operator[] (size_t index) const
 Standard indexing operator.
 
T & operator[] (size_t index)
 Non-const overload for the standard indexing operator.
 
iterator begin ()
 
iterator end ()
 
bool addValues (size_t numAddedValues, bool tight=false)
 Adds numAddedValues to the set, without any initialization. Returns true on success, false on error. On errors previous values are kept. If the vector is empty, the allocated size will be adjusted to exactly the given size. Otherwise, a growing factor of half of the previous size will be used, unless that is insufficient. If tight is set to true, the allocated size will always match the needed size (unless already allocated).
 
void restoreSize (size_t oldNumValues)
 Restores the size of the set to the previous size before the last call to addValues(). Can be called with the current size if addValues was not called.
 
void clear ()
 Clears all stored data returning the object to a default constructed state.
 
void zero (size_t index=0)
 Clears the vector area by setting to zero all entries starting at the given index.
 
size_t usedMemory () const
 Returns an estimative of the memory used by the data set in bytes.
 
int numDumpBuffers () const
 Returns the number of internal buffers used by this implementation.
 
char * dumpBuffer (int i) const
 Returns the i'th internal buffer, i from 0 to numDumpBuffers()-1.
 
size_t dumpBufferSize (int i) const
 Returns the size in bytes of the i'th internal buffer returned by dumpBuffer(i)
 

Private Member Functions

 Q_DISABLE_COPY (GmDualVectorR)
 

Private Attributes

size_t _size
 The total number of entries in the vector. Can be less than _fixedSize if entries where removed from the vector.
 

Additional Inherited Members

- Public Types inherited from GmDualVector< T >
typedef T DataType
 The stored data type.
 
- Protected Attributes inherited from GmDualVector< T >
T * _fixedData
 The fixed part of the dual vector with _fixedSize entries.
 
size_t _fixedSize
 The number of entries in _fixedData.
 
GmPODVector< T > _growData
 The variable part.
 

Detailed Description

template<class T>
class GmDualVectorR< T >

A class very simmilar to GmDualVector with support for removing values. Removing values should be used with caution. See the comments on the function.

Member Function Documentation

◆ removeValues()

template<class T >
void GmDualVectorR< T >::removeValues ( size_t index,
size_t numValues )
inline

Removes numValues from the set, starting from (and including) index.

Use this function with extreme caution if the vector is ever queried by calling iptr() with an added offset.

When removing entries, all or part of the fixed vector can become empty. If that space is reclaimed by a later grow, we could end up with part of a multidimensional value in the fixed vector and part in the grow vector. This is not acceptable for many use cases of this class, so make sure that this can not happend when combining removeValues() with iptr() + offset access.


The documentation for this class was generated from the following file: