9#include <gtest/gtest.h>
45 vector<int> v = {1, 2, 3, 4, 5};
62 vector<double> v = {1.5, 2.5, 3.5};
74 vector<int> v = {10, 20, 30, 40, 50};
82 vector<int> v = {1, 2, 3, 4, 5};
90 vector<int> v = {1, 2, 3};
116 vector<int> v = {10, 20, 30};
166 vector<int> v = {1, 2, 3, 4, 5};
167 auto result =
map_vector(v, [](
int x) {
return x * x; });
178 vector<int> v = {1, 2, 3};
189 auto result =
map_vector(empty, [](
int x) {
return x * 2; });
250 auto t =
make_tuple(
string(
"a"),
string(
"b"),
string(
"c"));
294 auto t =
make_tuple(
string(
"hello"),
string(
"world"));
317 vector<int> v = {1, 2, 3};
363 auto it = result.begin();
410 vector<int> v = {100, 200, 300};
420 vector<double>
original = {1.1, 2.2, 3.3, 4.4};
428 vector<int> empty_vec;
444 static_assert(std::is_same_v<IT3, index_tuple<0, 1, 2>>,
445 "make_index_tuple<3> should produce index_tuple<0, 1, 2>");
448 static_assert(std::is_same_v<IT0, index_tuple<>>,
449 "make_index_tuple<0> should produce index_tuple<>");
452 static_assert(std::is_same_v<IT1, index_tuple<0>>,
453 "make_index_tuple<1> should produce index_tuple<0>");
459 static_assert(std::is_same_v<IT, index_tuple<0, 1, 2>>,
460 "to_index_tuple with 3 types should produce index_tuple<0, 1, 2>");
469 const size_t N = 10000;
471 for (
size_t i = 0; i <
N; ++i)
472 v[i] =
static_cast<int>(i);
477 EXPECT_EQ(result.get_last(),
static_cast<int>(
N - 1));
513 "another long string for testing"};
520 EXPECT_EQ(v[0],
"long string that should not be copied");
521 EXPECT_EQ(v[1],
"another long string for testing");
Conversion utilities between Aleph-w containers and STL containers.
Functional programming utilities for Aleph-w containers.
T & append()
Allocate a new entry to the end of array.
Dynamic singly linked list with functional programming support.
T & get_first() const
Return the first item of the list.
void empty() noexcept
empty the list
Dynamic set backed by balanced binary search trees with automatic memory management.
Key * insert(const Key &key)
Inserts a key into the dynamic set.
size_t size() const noexcept
Count the number of elements of the list.
Rectangular point in the plane.
bool operator==(const Point &point) const
iterator end() noexcept
Return an STL-compatible end iterator.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
Main namespace for Aleph-w library functions.
Array< T > tuple_to_array(const std::tuple< T, U... > &t)
Convert a tuple to an Array.
auto range_to_DynList(Iterator begin, Iterator end) -> DynList< std::decay_t< decltype(*begin)> >
Convert an iterator range to a DynList.
DynList< T > to_DynList(const Array< T > &a)
Convert an Array to a DynList.
DynList< T > list_to_DynList(const std::list< T > &l)
Convert a std::list to a DynList.
typename make_index_tuple< sizeof...(Types)>::type to_index_tuple
Convenience alias to generate an index tuple from a parameter pack.
DynList< T > vector_to_DynList(const std::vector< T > &v)
Convert a std::vector to a DynList.
DynList< T > tuple_to_dynlist(const std::tuple< T, U... > &t)
Convert a tuple to a DynList.
auto stl_container_to_dynList(const StlContainer &container) -> DynList< typename StlContainer::value_type >
Convert any STL container to a DynList.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
Array< typename C::Item_Type > to_Array(const C &c)
Convert a container to an Array.
DynArray< T > vector_to_DynArray(const std::vector< T > &v)
Convert a std::vector to a DynArray.
std::vector< T > DynArray_to_vector(const DynArray< T > &arr)
Convert a DynArray to a std::vector.
std::list< T > DynList_to_list(const DynList< T > &l)
Convert a DynList to a std::list.
void tuple_for_each(const std::tuple< Ts... > &tuple, F func, std::index_sequence< Is... >)
Apply a function to each element in a tuple (tuple first).
std::vector< typename C::Item_Type > to_vector(const C &c)
Convert a container to a std::vector.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
auto map_vector(const std::vector< T > &v, Op op) -> std::vector< std::decay_t< decltype(op(v[0]))> >
Map a function over a std::vector.
typename make_index_tuple< Size-1 >::type::template append< Size-1 > type