File MultiIndex.hpp

namespace Acts


This file is foreseen for the Geometry module to replace Extent

template<typename T, std::size_t... BitsPerLevel>
class MultiIndex
#include <Acts/Utilities/MultiIndex.hpp>

A set of (hierachical) indices bitpacked into a single value.

The underlying value is split into blocks of bits with variable size. Each block is a level within the index hierachy and can be set and retrieved separately. The encoded MultiIndex can be ordered and compared for equality. The ordering follows the hiearchy, i.e. indices are first ordered by the highest level, then within the highest level by the second level and so on.

Public Types

enum [anonymous]


enumerator NumLevels
using Value = T

The type of ther underlying storage value.

Public Functions

inline constexpr MultiIndex(Value encoded)

Construct a MultiIndex from an already encoded value.

MultiIndex() = default

Construct a default MultiIndex with undefined values for each level.

MultiIndex(const MultiIndex&) = default
MultiIndex(MultiIndex&) = default
inline constexpr Value level(std::size_t lvl) const

Get the value for the index level.

inline constexpr MultiIndex makeLastDescendant(std::size_t lvl) const

Create index with every level below the selected level maximized.

inline constexpr MultiIndex makeNextSibling(std::size_t lvl) const

Create index with the selected level increased and levels below zeroed.

MultiIndex &operator=(const MultiIndex&) = default
MultiIndex &operator=(MultiIndex&&) = default
inline constexpr MultiIndex &operator=(Value encoded)

Allow setting the MultiIndex from an already encoded value.

inline constexpr MultiIndex &set(std::size_t lvl, Value val)

Set the value of the index level.

inline constexpr Value value() const

Get the encoded value of all index levels.

Public Static Functions

static inline constexpr std::size_t bits(std::size_t lvl)

Get the number of bits for the associated level.

template<typename ...Us>
static inline constexpr MultiIndex Encode(Us&&... us)

Construct a MultiIndex from values for multiple level.

This functionality must be implemented as a static, named constructor to avoid confusion with other constructors. If it would be implemented as a regular constructor, constructing a MultiIndex from a single encoded value and encoding only the first level would have the same signature and could not be distinguished.

static inline constexpr MultiIndex Zeros()

Construct a MultiIndex with all levels set to zero.

Private Members

Value m_value

Private Static Functions

static inline constexpr Value mask(std::size_t lvl)
static inline constexpr std::size_t shift(std::size_t lvl)

Private Static Attributes

static constexpr std::array<std::size_t, NumLevels> s_bits = {BitsPerLevel...}


inline friend constexpr bool operator<(MultiIndex lhs, MultiIndex rhs)
inline friend std::ostream &operator<<(std::ostream &os, MultiIndex idx)
inline friend constexpr bool operator==(MultiIndex lhs, MultiIndex rhs)