diff --git a/include/mir/ndslice.h b/include/mir/ndslice.h index ce7af942..9f73e75d 100644 --- a/include/mir/ndslice.h +++ b/include/mir/ndslice.h @@ -253,6 +253,16 @@ struct mir_slice return _iterator[index]; } + auto&& backward(mir_size_t index) + { + return at(size() - 1 - index); + } + + auto&& backward(mir_size_t index) const + { + return at(size() - 1 - index); + } + auto&& operator[](mir_size_t index) { return at(index); diff --git a/include/mir/series.h b/include/mir/series.h index 77cbfbd2..7f532174 100644 --- a/include/mir/series.h +++ b/include/mir/series.h @@ -71,6 +71,11 @@ struct mir_series return {_index[index], _data[index]}; } + Observation backward(mir_size_t index) const noexcept + { + return {_index[size() - 1 - index], _data[size() - 1 - index]}; + } + Observation operator[](mir_size_t index) const noexcept { return {_index[index], _data[index]};