HerdSoftware
0.1.1
|
An array that accepts directions as subscripts. More...
#include <DirectionsArray.h>
Public Types | |
using | BaseType = ArrayForwarder< ContainedClass, RefFrame::NDirections > |
![]() | |
typedef ContainedClass | value_type |
typedef value_type * | pointer |
typedef const value_type * | const_pointer |
typedef value_type & | reference |
typedef const value_type & | const_reference |
typedef value_type * | iterator |
typedef const value_type * | const_iterator |
typedef std::size_t | size_type |
typedef std::ptrdiff_t | difference_type |
typedef std::reverse_iterator< iterator > | reverse_iterator |
typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
Public Member Functions | |
ContainedClass & | operator[] (const RefFrame::Direction &direction) |
Accesses an element without validity check on the element index. More... | |
const ContainedClass & | operator[] (const RefFrame::Direction &direction) const |
Accesses an element without validity check on the element index. More... | |
ContainedClass & | at (const RefFrame::Direction &direction) |
Accesses an element with validity check on the element index. More... | |
const ContainedClass & | at (const RefFrame::Direction &direction) const |
Accesses an element with validity check on the element index. More... | |
![]() | |
ArrayForwarder () | |
ArrayForwarder (std::array< ContainedClass, _Nm > arr) | |
void | fill (const value_type &__u) |
void | swap (ArrayForwarder &__other) noexcept(noexcept(std::swap(std::declval< ContainedClass & >(), std::declval< ContainedClass & >()))) |
_GLIBCXX17_CONSTEXPR iterator | begin () noexcept |
_GLIBCXX17_CONSTEXPR const_iterator | begin () const noexcept |
_GLIBCXX17_CONSTEXPR iterator | end () noexcept |
_GLIBCXX17_CONSTEXPR const_iterator | end () const noexcept |
_GLIBCXX17_CONSTEXPR reverse_iterator | rbegin () noexcept |
_GLIBCXX17_CONSTEXPR const_reverse_iterator | rbegin () const noexcept |
_GLIBCXX17_CONSTEXPR reverse_iterator | rend () noexcept |
_GLIBCXX17_CONSTEXPR const_reverse_iterator | rend () const noexcept |
_GLIBCXX17_CONSTEXPR const_iterator | cbegin () const noexcept |
_GLIBCXX17_CONSTEXPR const_iterator | cend () const noexcept |
_GLIBCXX17_CONSTEXPR const_reverse_iterator | crbegin () const noexcept |
_GLIBCXX17_CONSTEXPR const_reverse_iterator | crend () const noexcept |
constexpr size_type | size () const noexcept |
constexpr size_type | max_size () const noexcept |
constexpr bool | empty () const noexcept |
_GLIBCXX17_CONSTEXPR reference | operator[] (size_type __n) noexcept |
constexpr const_reference | operator[] (size_type __n) const noexcept |
_GLIBCXX17_CONSTEXPR reference | at (size_type __n) |
constexpr const_reference | at (size_type __n) const |
_GLIBCXX17_CONSTEXPR reference | front () noexcept |
constexpr const_reference | front () const noexcept |
_GLIBCXX17_CONSTEXPR reference | back () noexcept |
constexpr const_reference | back () const noexcept |
_GLIBCXX17_CONSTEXPR pointer | data () noexcept |
_GLIBCXX17_CONSTEXPR const_pointer | data () const noexcept |
An array that accepts directions as subscripts.
A DirectionsArray contains elements associated to each direction of the Herd detector. The elements in an DirectionsArray can be indexed using RefFrame::Direction values. The class does not support the braced initialization lists like std::array, since it doesn't guarantee any relation between the position in the initializer list and the direction value. So it is not possible to initialize Direction Array as:
The typical usage of a DirectionsArray involves the subscript operator together with a RefFrame::Direction used as the subscript index. For example, suppose to have to store one integer value for each direction:
To set the value of the Zpos element to 1 and of the Xneg element to 2:
This brief example shows the main purpose of the DirectionsArray: using a RefFrame::Direction to index the directions instead of integers removes a potential source of confusion, e.g.:
With the help of RefFrame::Directions and of RefFrame::NDirections is it also possible to loop over all the values of a DirectionsArray with a range-for loop, e.g.:
or with a "classic" for loop:
using Herd::DirectionsArray< ContainedClass >::BaseType = ArrayForwarder<ContainedClass, RefFrame::NDirections> |
|
inline |
Accesses an element with validity check on the element index.
Accesses the element corresponding to the given direction; if the direction is NONE then a std::out_of_range exception will be thrown.
direction | The direction of the desired element. |
std::out_of_range | if direction == RefFrame::Direction::NONE. |
|
inline |
Accesses an element with validity check on the element index.
Accesses the element corresponding to the given direction; if the direction is NONE then a std::out_of_range exception will be thrown.
direction | The direction of the desired element. |
std::out_of_range | if direction == RefFrame::Direction::NONE. |
|
inline |
Accesses an element without validity check on the element index.
Accesses the element corresponding to the given direction. No check is performed on the direction argument, so passing NONE will result in undefined behavior.
direction | The direction of the desired element. |
|
inline |
Accesses an element without validity check on the element index.
Accesses the element corresponding to the given direction. No check is performed on the direction argument, so passing NONE will result in undefined behavior.
direction | The direction of the desired element. |