WaveBlocksND
Classes | Public Member Functions | Public Attributes | Static Public Attributes | Static Private Member Functions | Friends | List of all members
waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D > Class Template Reference

Represents a multi-index using a single integer. More...

#include <tiny_multi_index.hpp>

Classes

class  Entry
 

Public Member Functions

 TinyMultiIndex ()
 
 TinyMultiIndex (const TinyMultiIndex &that)
 
 TinyMultiIndex (const std::array< int, D > &that)
 
 TinyMultiIndex (std::initializer_list< int > list)
 
TinyMultiIndexoperator= (const TinyMultiIndex &that)
 
int operator[] (dim_t index) const
 
Entry operator[] (dim_t index)
 
bool operator== (const TinyMultiIndex &that) const
 
bool operator!= (const TinyMultiIndex &that) const
 
 operator std::array< int, D > () const
 

Public Attributes

UINT values_ = 0
 

Static Public Attributes

static const std::size_t BITS_PER_ENTRY = (8*sizeof(UINT))/D
 

Static Private Member Functions

static int limit (dim_t axis)
 

Friends

struct std::less< waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D > >
 
struct std::hash< waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D > >
 
struct std::equal_to< waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D > >
 

Detailed Description

template<class UINT, dim_t D>
class waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >

Represents a multi-index using a single integer.

This implementation splits an integer into same sized parts. For example, using a 64bit integer to represent a 10-dimensional multi-index: The largest index it can represent is 63 (6 bits). This means when using this class, special care must be taken to prevent overflows. Thus, code that uses multi-indices should ensure that a multi-index type is viable:

MultiIndex mindex;
for (dim_t d = 0; d < D; d++) {
mindex[d] = largest_possible_index;
if (mindex[d] != largest_possible_index)
throw std::runtime_error("multi-index type is not compatible!");
}

If TinyMultiIndex is not enough for you. You will have to implement your own type. A custom implementation must possess the same semantics as std::array<int,D>. Furthermore it has to specialize std::less, that performs lexical index comparison beginning on the first index. And it has to specialize std::equal_to and std::hash to enable use of multi-indices as hashtable keys.

Template Parameters
UINTOption to select, which integer type is used.
DDimensionality of multi-index i.e number of entries.

Constructor & Destructor Documentation

template<class UINT , dim_t D>
waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::TinyMultiIndex ( )
inline
template<class UINT , dim_t D>
waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::TinyMultiIndex ( const TinyMultiIndex< UINT, D > &  that)
inline
template<class UINT , dim_t D>
waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::TinyMultiIndex ( const std::array< int, D > &  that)
inline
template<class UINT , dim_t D>
waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::TinyMultiIndex ( std::initializer_list< int >  list)
inline

Member Function Documentation

template<class UINT , dim_t D>
static int waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::limit ( dim_t  axis)
inlinestaticprivate

for a given axis: returns the largest value that this implementation is able to store

template<class UINT , dim_t D>
waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::operator std::array< int, D > ( ) const
inline
template<class UINT , dim_t D>
bool waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::operator!= ( const TinyMultiIndex< UINT, D > &  that) const
inline
template<class UINT , dim_t D>
TinyMultiIndex& waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::operator= ( const TinyMultiIndex< UINT, D > &  that)
inline
template<class UINT , dim_t D>
bool waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::operator== ( const TinyMultiIndex< UINT, D > &  that) const
inline
template<class UINT , dim_t D>
int waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::operator[] ( dim_t  index) const
inline
template<class UINT , dim_t D>
Entry waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::operator[] ( dim_t  index)
inline

Friends And Related Function Documentation

template<class UINT , dim_t D>
friend struct std::equal_to< waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D > >
friend
template<class UINT , dim_t D>
friend struct std::hash< waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D > >
friend
template<class UINT , dim_t D>
friend struct std::less< waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D > >
friend

Member Data Documentation

template<class UINT , dim_t D>
const std::size_t waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::BITS_PER_ENTRY = (8*sizeof(UINT))/D
static
template<class UINT , dim_t D>
UINT waveblocks::wavepackets::shapes::TinyMultiIndex< UINT, D >::values_ = 0

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