xaxis_default

Defined in xframe/xaxis_default.hpp

template<class L, class T = std::size_t>
class xaxis_default : public xf::xaxis_base<xaxis_default<L, T>>

Default axis with integral labels.

The xaxis_default class is used for modeling a default axis that holds a contiguous sequence of integral labels starting at 0.

Template Parameters
  • L: the type of labels. This must be an integral type.

  • T: the integer type used to represent positions. Default value is std::size_t.

Public Functions

xaxis_default(size_type size = 0)

Constructs a default axis holding size integral elements.

The labels sequence is [0, 1, ….. size - 1)

bool is_sorted() const

Returns true if the labels list is sorted.

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.

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 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.

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.

template<class T = std::size_t, class L>
xaxis_default<L, T> xf::axis(L size)

Returns a default axis that holds size integral labels.

Parameters
  • size: the number of labels.

Template Parameters
  • T: the integral type used for positions. Default value is std::size_t.

  • L: the type of the labels. This must be an integral type.