xaxis_variant

Defined in xframe/xaxis_variant.hpp

template<class L, class T, class MT = hash_map_tag>
class xaxis_variant

Axis whose label type is a variant.

The xaxis_variant holds a variant of axes with different label types. It provides the same API as a regular axis, wrapping the visitor mechanism required to access the underlying axis. This allows to store axes with different label types in a coordinate system.

Template Parameters
  • L: the type list of labels

  • T: the integer type used to represent positions.

  • MT: the tag used for choosing the map type which holds the label- position pairs. Possible values are map_tag and hash_map_tag. Default value is hash_map_tag.

Constructors

template<class LB>
xaxis_variant(const xaxis<LB, T, MT> &axis)

Constructs an xaxis_variant from the specified xaxis.

This latter is copied in the variant.

Template Parameters
  • LB: the label type of the axis argument.

Parameters
  • axis: the axis to copy in the variant.

template<class LB>
xaxis_variant(xaxis<LB, T, MT> &&axis)

Constructs an xaxis_variant from the specified xaxis.

This latter is moved in the variant.

Template Parameters
  • LB: the label type of the axis argument.

Parameters
  • axis: the axis to move in the variant.

template<class LB>
xaxis_variant(const xaxis_default<LB, T> &axis)

Constructs an xaxis_variant from the specified xaxis_default.

This latter is copied in the variant.

Template Parameters
  • LB: the label type of the axis argument.

Parameters
  • axis: the axis to copy in the variant.

template<class LB>
xaxis_variant(xaxis_default<LB, T> &&axis)

Constructs an xaxis_variant from the specified xaxis_default.

This latter is moved in the variant.

Template Parameters
  • LB: the label type of the axis argument.

Parameters
  • axis: the axis to move in the variant.

Data

bool contains(const key_type &key) const

Returns true if the axis contains the speficied label.

Parameters
  • key: the label to search for.

auto operator[](const key_type &key) const

Returns the position of the specified label.

If this last one is not found, an exception is thrown.

Parameters
  • key: the label to search for.

Filters

template<class F>
auto filter(const F &f) const

Builds an return a new axis by applying the given filter to the axis.

Parameters
  • f: the filter used to select the labels to keep in the new axis.

template<class F>
auto filter(const F &f, size_type size) const

Builds an return a new axis by applying the given filter to the axis.

When the size of the new list of labels is known, this method allows some optimizations compared to the previous one.

Parameters
  • f: the filter used to select the labels to keep in the new axis.

  • size: the size of the new label list.

Set operations

template<class ...Args>
bool merge(const Args&... axes)

Merges all the axes arguments into this ones.

After this function call, the axis contains all the labels from all the arguments.

Return

true is the axis already contained all the labels.

Parameters
  • axes: the axes to merge.

template<class ...Args>
bool intersect(const Args&... axes)

Replaces the labels with the intersection of the labels of the axes arguments and the labels of this axis.

Return

true if the intersection is equivalent to this axis.

Parameters
  • axes: the axes to intersect.

Labels

auto labels() const

Returns the list of labels contained in the axis.

auto label(size_type i) const

Return the i-th label of the axis.

Parameters
  • i: the position of the label.

bool empty() const

Checks if the axis has no labels.

auto size() const

Returns the number of labels in the axis.

bool is_sorted() const

Returns true if the labels list is sorted.

Iterators

auto find(const key_type &key) const

Returns a constant iterator to the element with label equivalent to key.

If no such element is found, past-the-end iterator is returned.

Parameters
  • key: the label to search for.

auto begin() const

Returns a constant iterator to the first element of the axis.

This element is a pair label - position.

auto end() const

Returns a constant iterator to the element following the last element of the axis.

auto cbegin() const

Returns a constant iterator to the first element of the axis.

This element is a pair label - position.

auto cend() const

Returns a constant iterator to the element following the last element of the axis.

auto rbegin() const

Returns a constant iterator to the first element of the reverse axis.

This element is a pair labal - position.

auto rend() const

Returns a constant iterator to the element following the last element of the reversed axis.

auto crbegin() const

Returns a constant iterator to the first element of the reverse axis.

This element is a pair labal - position.

auto crend() const

Returns a constant iterator to the element following the last element of the reversed axis.

Public Functions

bool operator==(const self_type &rhs) const

Returns true is this axis and rhs are equivalent axes, i.e.

they contain the same label - position pairs.

Parameters
  • rhs: an axis.

bool operator!=(const self_type &rhs) const

Returns true is this axis and rhs are not equivalent axes, i.e.

they contain different label - position pairs.

Parameters
  • rhs: an axis.