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
-
UINT | Option to select, which integer type is used. |
D | Dimensionality of multi-index i.e number of entries. |