Nebula
Loading...
Searching...
No Matches
Util::SparseTable< TYPE > Class Template Reference

#include <sparsetable.h>

Detailed Description

template<class TYPE>
class Util::SparseTable< TYPE >

A 2D sparse table where many entries may be redundant and support for multiple entries per cell.

Classes

struct  TableEntry
 a table entry in the sparse table More...

Public Member Functions

 SparseTable ()
 constructor
void BeginSetup (const Array< StringAtom > &columnNames, const Array< StringAtom > &rowNames, SizeT numUnique=0)
 setup the sparse table
void AddSingle (IndexT colIndex, IndexT rowIndex, const TYPE &elm)
 add a single new unique entry
void AddMultiple (IndexT colIndex, IndexT rowIndex, const TYPE *firstElm, SizeT numElements)
 add a new multiple entry
void AddReference (IndexT colIndex, IndexT rowIndex, IndexT refColIndex, IndexT refRowIndex)
 add a reference to another column/index
void SetEntryDirect (IndexT colIndex, IndexT rowIndex, ushort startIndex, ushort numElements)
 add a direct reference using an index into the unique element array
void EndSetup ()
 finish setting up the sparse table
void Clear ()
 clear object
SizeT GetNumColumns () const
 get number of columns in the sparse table
SizeT GetNumRows () const
 get number of rows in the sparse table
bool HasColumn (const StringAtom &colName) const
 return true if column exists
bool HasRow (const StringAtom &rowName) const
 return true if row exists
IndexT GetColumnIndexByName (const StringAtom &colName) const
 return column index by name
IndexT GetRowIndexByName (const StringAtom &rowName) const
 return row index by name
SizeT GetNumUniqueElements () const
 get current number of unique elements
const TYPE * GetElements (IndexT colIndex, IndexT rowIndex, SizeT &outNumElements) const
 get entry at given index
const TYPE * LookupElements (const StringAtom &colName, const StringAtom &rowName, SizeT &outNumElements) const
 lookup entry by row/column names

Private Attributes

Array< TYPE > uniqueElements
FixedTable< TableEntrytableEntries
Dictionary< StringAtom, IndexTcolIndexMap
Dictionary< StringAtom, IndexTrowIndexMap
bool inSetup

Constructor & Destructor Documentation

◆ SparseTable()

template<class TYPE>
Util::SparseTable< TYPE >::SparseTable ( )

constructor

Member Function Documentation

◆ AddMultiple()

template<class TYPE>
void Util::SparseTable< TYPE >::AddMultiple ( IndexT colIndex,
IndexT rowIndex,
const TYPE * firstElm,
SizeT numElements )

add a new multiple entry

◆ AddReference()

template<class TYPE>
void Util::SparseTable< TYPE >::AddReference ( IndexT colIndex,
IndexT rowIndex,
IndexT refColIndex,
IndexT refRowIndex )

add a reference to another column/index

NOTE: forward references are not allowed!

◆ AddSingle()

template<class TYPE>
void Util::SparseTable< TYPE >::AddSingle ( IndexT colIndex,
IndexT rowIndex,
const TYPE & elm )

add a single new unique entry

◆ BeginSetup()

template<class TYPE>
void Util::SparseTable< TYPE >::BeginSetup ( const Array< StringAtom > & columnNames,
const Array< StringAtom > & rowNames,
SizeT numUnique = 0 )

setup the sparse table

◆ Clear()

template<class TYPE>
void Util::SparseTable< TYPE >::Clear ( )

clear object

◆ EndSetup()

template<class TYPE>
void Util::SparseTable< TYPE >::EndSetup ( )

finish setting up the sparse table

◆ GetColumnIndexByName()

template<class TYPE>
IndexT Util::SparseTable< TYPE >::GetColumnIndexByName ( const StringAtom & colName) const

return column index by name

◆ GetElements()

template<class TYPE>
const TYPE * Util::SparseTable< TYPE >::GetElements ( IndexT colIndex,
IndexT rowIndex,
SizeT & outNumElements ) const

get entry at given index

◆ GetNumColumns()

template<class TYPE>
SizeT Util::SparseTable< TYPE >::GetNumColumns ( ) const

get number of columns in the sparse table

◆ GetNumRows()

template<class TYPE>
SizeT Util::SparseTable< TYPE >::GetNumRows ( ) const

get number of rows in the sparse table

◆ GetNumUniqueElements()

template<class TYPE>
SizeT Util::SparseTable< TYPE >::GetNumUniqueElements ( ) const

get current number of unique elements

◆ GetRowIndexByName()

template<class TYPE>
IndexT Util::SparseTable< TYPE >::GetRowIndexByName ( const StringAtom & rowName) const

return row index by name

◆ HasColumn()

template<class TYPE>
bool Util::SparseTable< TYPE >::HasColumn ( const StringAtom & colName) const

return true if column exists

◆ HasRow()

template<class TYPE>
bool Util::SparseTable< TYPE >::HasRow ( const StringAtom & rowName) const

return true if row exists

◆ LookupElements()

template<class TYPE>
const TYPE * Util::SparseTable< TYPE >::LookupElements ( const StringAtom & colName,
const StringAtom & rowName,
SizeT & outNumElements ) const

lookup entry by row/column names

◆ SetEntryDirect()

template<class TYPE>
void Util::SparseTable< TYPE >::SetEntryDirect ( IndexT colIndex,
IndexT rowIndex,
ushort startIndex,
ushort numElements )

add a direct reference using an index into the unique element array

Member Data Documentation

◆ colIndexMap

template<class TYPE>
Dictionary<StringAtom, IndexT> Util::SparseTable< TYPE >::colIndexMap
private

◆ inSetup

template<class TYPE>
bool Util::SparseTable< TYPE >::inSetup
private

◆ rowIndexMap

template<class TYPE>
Dictionary<StringAtom, IndexT> Util::SparseTable< TYPE >::rowIndexMap
private

◆ tableEntries

template<class TYPE>
FixedTable<TableEntry> Util::SparseTable< TYPE >::tableEntries
private

◆ uniqueElements

template<class TYPE>
Array<TYPE> Util::SparseTable< TYPE >::uniqueElements
private

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