Free Electron
Public Member Functions | Private Member Functions | Private Attributes | Related Functions | List of all members
fe::ext::SparseArray< T > Class Template Reference

Row-Compressed Sparse Container. More...

#include <SparseArray.h>

Public Member Functions

 SparseArray (U32 prealloc=FE_SA_PREALLOC)
 
 SparseArray (const SparseArray< T > &other)
 
SparseArray< T > & operator= (const SparseArray< T > &other)
 
void reset (U32 prealloc=FE_SA_PREALLOC)
 Remove all existing values. More...
 
void clear (void)
 Zero existing values, but do not remove. More...
 
U32 size (void) const
 Return the largest index. More...
 
T & operator[] (U32 index)
 Return the entry at the particular index. More...
 
operator[] (U32 index) const
 Return the const entry at the particular index. More...
 
U32 entries (void) const
 Return the number of actual stored entries. More...
 
U32 index (U32 location) const
 Return the index at a storage location. More...
 
T & entry (U32 location)
 Return the entry at a storage location. More...
 
entry (U32 location) const
 Return the const entry at a storage location. More...
 

Private Member Functions

void grow (void)
 
void initialize (U32 prealloc)
 

Private Attributes

U32 m_allocated
 
U32 m_used
 
U32 m_maxIndex
 
U32 m_cacheLocation
 
U32 * m_pIndex
 
T * m_pData
 

Related Functions

(Note that these are not member functions.)

template<class T >
String print (const SparseArray< T > &rhs, BWORD sparse=FALSE)
 Print to a string. More...
 

Detailed Description

template<class T>
class fe::ext::SparseArray< T >

Row-Compressed Sparse Container.

Member Function Documentation

◆ clear()

template<class T >
void fe::ext::SparseArray< T >::clear ( void  )
inline

Zero existing values, but do not remove.

Referenced by fe::ext::SparseArray< T >::operator[]().

◆ entries()

template<class T>
U32 fe::ext::SparseArray< T >::entries ( void  ) const
inline

Return the number of actual stored entries.

This can be less than the size. Using entry() instead of operator[] can be helpful to limit an iteration to only the values that are actually set, instead of reading lots of zeros.

◆ entry() [1/2]

template<class T>
T& fe::ext::SparseArray< T >::entry ( U32  location)
inline

Return the entry at a storage location.

◆ entry() [2/2]

template<class T>
T fe::ext::SparseArray< T >::entry ( U32  location) const
inline

Return the const entry at a storage location.

◆ index()

template<class T>
U32 fe::ext::SparseArray< T >::index ( U32  location) const
inline

Return the index at a storage location.

Referenced by fe::ext::SparseArray< T >::operator[](), and fe::ext::SparseArray< T >::size().

◆ operator[]() [1/2]

template<class T >
T & fe::ext::SparseArray< T >::operator[] ( U32  index)
inline

Return the entry at the particular index.

References fe::ext::SparseArray< T >::index().

Referenced by fe::ext::SparseArray< T >::operator[](), and fe::ext::SparseArray< T >::size().

◆ operator[]() [2/2]

template<class T >
T fe::ext::SparseArray< T >::operator[] ( U32  index) const
inline

Return the const entry at the particular index.

References fe::ext::SparseArray< T >::clear(), and fe::ext::SparseArray< T >::operator[]().

◆ reset()

template<class T >
void fe::ext::SparseArray< T >::reset ( U32  prealloc = FE_SA_PREALLOC)
inline

Remove all existing values.

◆ size()

template<class T>
U32 fe::ext::SparseArray< T >::size ( void  ) const
inline

Friends And Related Function Documentation

◆ print()

template<class T >
String print ( const SparseArray< T > &  rhs,
BWORD  sparse = FALSE 
)
related

Print to a string.


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