9template <
typename Array>
11 { array.size() } -> std::convertible_to<size_t>;
12 {
static_cast<bool>(array.at(
index)) } -> std::same_as<bool>;
14 {
static_cast<bool>(array.slice(
index,
count)) } -> std::same_as<bool>;
15 { array.slice(
index,
count)->size() } -> std::convertible_to<size_t>;
45template <FieldArray Array>
112 template <
typename ValueT>
113 [[nodiscard]]
auto to_nddata(std::string_view field_name)
const
114 requires requires(
const Array& array, std::string_view
name) {
115 array.template to_nddata<ValueT>(
name);
118 return m_array->template to_nddata<ValueT>(field_name);
128 template <
typename ValueT>
130 requires requires(
const Array& array, std::string_view
name) {
131 array.slice(
size_t {},
size_t {})->
template to_nddata<ValueT>(
name);
135 using Result =
decltype(
window->template to_nddata<ValueT>(field_name));
136 return window ?
window->template to_nddata<ValueT>(field_name) : Result {};
146 template <
typename Fn>
149 for (
size_t i = 0; i <
m_array->size(); ++i) {
150 if (
auto element =
m_array->at(i))
151 std::invoke(fn, *element);
163 template <
typename Fn>
170 for (
size_t i = 0; i <
window->size(); ++i) {
171 if (
auto element =
window->at(i))
172 std::invoke(fn, *element);
187 template <
typename Acc,
typename Fn>
188 [[nodiscard]] Acc
reduce(Acc init, Fn&& fn)
const
190 for (
size_t i = 0; i <
m_array->size(); ++i) {
191 if (
auto element =
m_array->at(i))
192 init = std::invoke(fn, std::move(init), *element);
std::weak_ptr< Core::Window > window
void for_each_in_window(Fn &&fn) const
Apply a callable to each available element in the current window.
bool at_end() const
Whether there are no elements after the current position.
auto window_to_nddata(std::string_view field_name) const
Derive homogeneous NDData from one field in the current window.
void seek(size_t row)
Set the position, clamped to the end of the array.
void advance(size_t rows=0)
Move forward without passing the end of the array.
Acc reduce(Acc init, Fn &&fn) const
Fold all available elements into an accumulator.
size_t position() const noexcept
Current zero-based element position.
void for_each(Fn &&fn) const
Apply a callable to each available element in the array.
auto to_nddata(std::string_view field_name) const
Derive homogeneous NDData from one field across the entire array.
size_t batch_size() const noexcept
Current window size.
void set_batch_size(size_t rows) noexcept
Set the window size for subsequent operations.
auto current() const
Borrow the current window, including a short final window.
size_t remaining() const
Number of elements after the current position.
DataFieldTraversal(const Array &array, size_t batch_size=1) noexcept
Borrow an array and set the initial window size.
On-demand windowing and field operations over an indexed array.
Array with optional-like element and contiguous slice access.