45#include <gtest/gtest.h>
59 std::vector<int> items(
const C & c)
62 for (
auto it = c.get_it(); it.has_curr(); it.next_ne())
63 ret.push_back(it.get_curr());
68 struct Only_Aleph_Iterator
74 const std::vector<int> * v;
76 bool has_curr() const noexcept {
return i < v->size(); }
77 void next_ne() noexcept { ++i; }
78 int get_curr()
const {
return (*v)[i]; }
82 Iterator get_it()
const {
return Iterator{&v}; }
86 struct Only_Stl_Iterator
91 auto begin()
const {
return v.begin(); }
92 auto end()
const {
return v.end(); }
96TEST(AhConvertComposition, BothUnitsConvertTheSameWay)
98 const std::vector<int> v = {5, 3, 8, 1};
112 ASSERT_EQ(a.
size(), v.size());
113 ASSERT_EQ(b.
size(), v.size());
114 for (
size_t i = 0; i < v.size(); ++i)
116 EXPECT_EQ(a(i), v[i]);
117 EXPECT_EQ(b(i), v[i]);
121TEST(AhConvertComposition, ToVectorTakesWhatEitherHeaderTook)
123 EXPECT_EQ(
to_vector(Only_Aleph_Iterator{{1, 2, 3}}), (std::vector<int>{1, 2, 3}));
124 EXPECT_EQ(
to_vector(Only_Stl_Iterator{{4, 5}}), (std::vector<int>{4, 5}));
127 for (
int i : {3, 1, 2})
129 EXPECT_EQ(
to_vector(s), (std::vector<int>{1, 2, 3}));
Conversion utilities between Aleph-w and STL container types.
Conversion utilities between Aleph-w containers and STL containers.
Aleph::DynArray< int > other_unit_vector_to_DynArray(const std::vector< int > &v)
Aleph::DynList< int > other_unit_vector_to_DynList(const std::vector< int > &v)
std::vector< int > other_unit_to_vector(const Aleph::DynList< int > &l)
size_t size() const noexcept
Return the current dimension of array.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
Dynamic set backed by balanced binary search trees with automatic memory management.
Key * insert(const Key &key)
Inserts a key into the dynamic set.
Main namespace for Aleph-w library functions.
T Item_Type
Type of elements from the first container.
auto get_curr() const
Return the current tuple (bounds-checked).
DynList< T > vector_to_DynList(const std::vector< T > &v)
Convert a std::vector to a DynList.
bool has_curr() const noexcept
Return true if all underlying iterators are positioned on a valid item.
DynArray< T > vector_to_DynArray(const std::vector< T > &v)
Convert a std::vector to a DynArray.
std::vector< typename C::Item_Type > to_vector(const C &c)
Convert a container to a std::vector.
void next_ne() noexcept(noexcept(std::declval< Aleph::const_iterator_t< HeadC > & >().next_ne()) and noexcept(std::declval< ZipIterator< TailC... > & >().next_ne()))
Advance all underlying iterators (unchecked variant).