38# include <gtest/gtest.h>
43using namespace testing;
67 int ptr[4] = {0, 1, 2, 3};
76 for (
int i = 0; it.has_curr(); it.next(), ++i)
84 int data[4] = {1, 2, 3, 4};
89 const int values[4] = {1, 2, 3, 4};
91 static_assert(std::is_const_v<std::remove_reference_t<
decltype(view.
get_first())>>);
92 static_assert(std::is_const_v<std::remove_reference_t<
decltype(view.
get_last())>>);
93 static_assert(std::is_const_v<std::remove_pointer_t<
decltype(view.
get_base())>>);
94 static_assert(std::is_const_v<std::remove_reference_t<
decltype(view.
get_it().
get_curr())>>);
95 static_assert(
not std::is_assignable_v<
decltype(view.
get_first()),
int>);
100 for (
auto it = view.
get_it(); it.has_curr(); it.next_ne())
101 sum += it.get_curr();
103 EXPECT_EQ(view.
foldl(0, [](
const int &
acc,
const int &x) { return acc + x; }), 10);
135 int values[2] = {1, 2};
161constexpr size_t N = 29;
169 for (
size_t i = 0; i <
N; ++i, ++
n)
214 for (
size_t i = 0; it.has_curr(); it.next(), ++i)
222 for (
size_t i = 0; it.has_curr(); it.next(), ++i)
232 for (
size_t i = n - 1; it.has_curr(); it.prev(), --i)
254 for (
size_t i = 0; i <
dim; ++i)
TEST_F(Array_of_n_items, Iterator_with_simple_bounds)
Iterator wrapper for C++ raw arrays and circular buffers.
Lightweight wrapper that provides Aleph-w container interface for raw arrays.
T * get_base() const noexcept
Get the base pointer.
T & get_last() const
Get the last element.
T & get_first() const
Get the first element.
Iterator get_it() const
Get an iterator to the beginning.
constexpr size_t size() const noexcept
Get the number of elements.
constexpr bool is_empty() const noexcept
Check if the container is empty.
Iterator wrapper for C++ raw arrays.
T & get_curr() const
Get the current item with bounds checking.
void reset_last() noexcept
Reset the iterator to the last item.
void reset() noexcept
Reset the iterator to the first item.
void prev()
Move to the previous item with bounds checking.
void next()
Advance to the next item with bounds checking.
void reset_first() noexcept
Reset the iterator to the first item (alias for reset()).
bool has_curr() const noexcept
Check if there is a current valid item.
bool is_last() const noexcept
Check if positioned at the last item.
__T foldl(const __T &init, Op &op) const
Fold the elements of the container to a specific result.
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_dim_function > > dim(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
Array_Container< T > make_array_container(T *array, size_t n)
Create an Array_Container from a raw array.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.