xaxis¶
Defined in xframe/xaxis.hpp
-
template<class
L
, classT
= std::size_t, classMT
= hash_map_tag>
classxaxis
: 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 isstd::size_t
.MT
: the tag used for choosing the map type which holds the label- position pairs. Possible values aremap_tag
andhash_map_tag
. Default value ishash_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.
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
>
autofilter
(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
>
autofilter
(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
Public Functions
-
bool
is_sorted
() const¶ Returns true if the labels list is sorted.
-
template<class
T
= std::size_t, classL
>
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 is1
.
- Template Parameters
T
: the integral type used for positions. Default valueL
: the type of the labels.
-
template<class
T
= std::size_t, classL
>
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 isstd::size_t
.L
: the type of the labels.