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

Especialization of the GmSingleAppendBuffer class using the GmSparseMatrixTripletBuffer interface. More...

#include <gmSparseMatrixTripletData.h>

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

Public Member Functions

 GmSparseMatrixSingleTripletBuffer (size_t initSize, double resizeFactor=2.0, int numThreads=-1)
 Buffer constructor. See the description for the GmSingleAppendBuffer constructor.
 
virtual GmSparseMatrixTripletData< T > * sortedData (int nlin, GmSparseMatrixTripletBufferSortStrategy st)
 Similar to data() but returning a sorted vector, obtained by using the given strategy. The nlin parameter should inform the number of lines of the matrix and is used as the maximum value stored for a line or column in the triplet data.
 
- Public Member Functions inherited from GmSingleAppendBuffer< GmSparseMatrixTripletData< T >, GmSparseMatrixTripletBuffer< T > >
 GmSingleAppendBuffer (size_t initSize, double resizeFactor=2.0, int numThreads=-1)
 Buffer constructor. Can optionally pre allocate the buffer with initSize entries. If initSize is zero, a call to reserve() MUST be made before any append. The given resizeFactor controlls how the buffer grows in case of a resize. See the class comments for additional info.
 
 ~GmSingleAppendBuffer ()
 Destructor. Releases the allocated memory.
 
virtual void clear ()
 Releases the memory used by the buffer, returning it to a recently constructed state. Must be followed by a call to reserve() before the object is able to do any further appends. Must be called from the main thread only.
 
virtual void reserve (size_t bsize)
 See comments on the base class. Should not be called if the size was given in the constructor.
 
virtual void append (const T &val)
 Appends val to the buffer in a thread safe way. Can grow the buffer if needed.
 
virtual void appendFromThread (int tid, const T &val)
 Appends val to the buffer in a thread safe way, using the given tid to access TLS storage. Can grow the buffer if needed.
 
virtual size_t size () const
 Returns the number of entries in the buffer. Must be called from the main thread only.
 
virtual T * data ()
 Returns a vector filled with the buffer data. After this call, NO calls to append() can be made without a prior call to clear().
 
virtual size_t usedMemory () const
 Returns an estimative of the total memory used by the buffer in bytes.
 
- Public Member Functions inherited from GmSparseMatrixTripletBuffer< T >
- Public Member Functions inherited from GmAppendBuffer< GmSparseMatrixTripletData< T > >
virtual ~GmAppendBuffer ()
 Virtual destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from GmSparseMatrixTripletBuffer< T >
static int strToSortStrategy (const QString &str)
 Returns the sort strategy associated with the given string. Returns -1 if no match was found.
 
static const char * sortStrategyToStr (GmSparseMatrixTripletBufferSortStrategy st)
 Returns the string used to define the given sort strategy.
 
- Protected Member Functions inherited from GmSingleAppendBuffer< GmSparseMatrixTripletData< T >, GmSparseMatrixTripletBuffer< T > >
void clearList ()
 
- Protected Attributes inherited from GmSingleAppendBuffer< GmSparseMatrixTripletData< T >, GmSparseMatrixTripletBuffer< T > >
ControllData * _head
 Pointer to the first allocated buffer.
 
double _resizeFactor
 The resize factor.
 
QAtomicInteger< size_t > _nextIndex
 The next free index in the global vector.
 
QAtomicPointer< ControllData > _controll
 The controll block pointing to the current buffer.
 
GmSpinLock _controllLock
 The lock controlling changes to _controll.
 
T * _dataBuffer
 The single buffer after a call to data()
 
int _nt
 Number of threads considered for parallel memcopy.
 

Detailed Description

template<GmSparseMatrixLayoutTypes T>
class GmSparseMatrixSingleTripletBuffer< T >

Especialization of the GmSingleAppendBuffer class using the GmSparseMatrixTripletBuffer interface.

Member Function Documentation

◆ sortedData()

Similar to data() but returning a sorted vector, obtained by using the given strategy. The nlin parameter should inform the number of lines of the matrix and is used as the maximum value stored for a line or column in the triplet data.

IMPORTANT: You should not mix calls to data() and sortedData() without a call to clear() in between.

Implements GmSparseMatrixTripletBuffer< T >.


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