xaxis

Defined in xframe/xaxis.hpp

template<class L, class T = std::size_t, class MT = hash_map_tag>
class xaxis : public xf::xaxis_base<xaxis<L, T, MT>>

Class modeling an axis in a coordinate system.

The xaxis class is used for modeling general axes; an axis is a mapping of labels to positions in a given dimension. It is the equivalent of the Index object from pandas.

Template Parameters
  • L: the type of labels.

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

  • 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

xaxis()

Constructs an empty axis.

xaxis(const label_list &labels)

Constructs an axis with the given list of labels.

This list is copied and the constructor internally checks whether it is sorted.

Parameters
  • labels: the list of labels.

xaxis(label_list &&labels)

Constructs an axis with the given list of labels.

The list is moved and therefore it is invalid after the axis has been constructed. The constructor internally checks whether the list is sorted.

Parameters
  • labels: the list of labels.

xaxis(std::initializer_list<key_type> init)

Constructs an axis from the given initializer list of labels.

The constructor internally checks whether the list is sorted.

template<class L1>
xaxis(xaxis_default<L1, T> axis)

Constructs an axis from a default_axis.

See

default_axis

template<class InputIt>
xaxis(InputIt first, InputIt last)

Constructs an axis from the content of the range [first, last)

Parameters
  • first: An iterator to the first label.

  • last: An iterator the the element following the last label.

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.

Iterator

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.

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.

Public Functions

bool is_sorted() const

Returns true if the labels list is sorted.

template<class T = std::size_t, class L>
xaxis<L, T> xf::axis(L start, L stop, L step = 1)

Returns an axis containing a range of integral labels.

Parameters
  • start: the first value of the range.

  • stop: the end of the range. The range doe snot contain this value.

  • step: Spacing between values. Default step is 1.

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

  • L: the type of the labels.

template<class T = std::size_t, class L>
xaxis<L, T> xf::axis(std::initializer_list<L> init)

Builds an returns an axis from the specified list of labels.

Parameters
  • init: the list of labels.

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

  • L: the type of the labels.