38#include <gtest/gtest.h>
79 for (
auto it = list.get_it(); it.has_curr(); it.next_ne())
172 for (
int i = 0; i < 10; ++i)
179 for (
auto it = list.get_it(); it.has_curr(); it.next_ne(), ++idx)
206 for (
int i = 0; i < 5; ++i)
212 for (
size_t i = 0; i < 5; ++i)
213 EXPECT_EQ(arr(i),
static_cast<int>(i) + 100);
270 std::vector<int>
vec;
277 std::vector<int>
vec = {123};
286 std::vector<int>
vec = {5, 10, 15, 20};
291 for (
auto it = list.get_it(); it.has_curr(); it.next_ne())
302 std::vector<int>
vec;
309 std::vector<int>
vec = {999};
318 std::vector<std::string>
vec = {
"a",
"b",
"c",
"d"};
357 auto it2 = result.get_it();
358 while (it1.has_curr())
360 EXPECT_EQ(it1.get_curr(), it2.get_curr());
368 std::vector<int>
original = {100, 200, 300, 400};
379 std::vector<double>
original = {1.5, 2.5, 3.5};
393 constexpr size_t SIZE = 10000;
395 for (
size_t i = 0; i <
SIZE; ++i)
396 arr.
append(
static_cast<int>(i));
404 for (
size_t i = 0; i <
SIZE; ++i)
410 std::vector<int>
vec;
411 constexpr size_t SIZE = 10000;
413 for (
size_t i = 0; i <
SIZE; ++i)
414 vec.push_back(
static_cast<int>(i * 2));
422 for (
size_t i = 0; i <
SIZE; ++i)
423 EXPECT_EQ(result[i],
static_cast<int>(i * 2));
430 std::vector<int>
vec;
437 std::vector<int>
vec = {42};
446 std::vector<std::string>
vec = {
"alpha",
"beta",
"gamma"};
588 std::deque<int>
deq = {5, 10, 15};
593 for (
auto it = list.get_it(); it.has_curr(); it.next_ne())
609 std::deque<int>
deq = {11, 22, 33, 44};
628 std::deque<double>
deq = {1.1, 2.2, 3.3};
657 for (
auto it = list.get_it(); it.has_curr(); it.next_ne())
682 for (
auto it = dlist.get_it(); it.has_curr(); it.next_ne())
729 for (
auto it = dlist.get_it(); it.has_curr(); it.next_ne())
738 std::vector<int>
vec;
745 std::vector<std::string>
vec = {
"a",
"b",
"c"};
749 auto it = dlist.get_it();
761 std::vector<int>
original = {1, 2, 3, 4, 5};
782 auto it2 = result.get_it();
783 while (it1.has_curr())
785 EXPECT_EQ(it1.get_curr(), it2.get_curr());
793 std::deque<double>
original = {1.5, 2.5, 3.5};
806 std::vector<std::string>
vec = {
"hello",
"world",
"test"};
812 auto it = list.get_it();
822 std::vector<std::string>
vec = {
"alpha",
"beta"};
834 std::vector<std::string>
vec = {
"x",
"y",
"z"};
847 std::vector<std::string>
vec = {
"one",
"two"};
853 auto it = dlist.get_it();
870 std::set<int> s = {3, 1, 4, 1, 5, 9};
874 auto it = list.get_it();
888 std::set<std::string> s = {
"banana",
"apple",
"cherry"};
899 std::set<int> s = {10, 20, 30};
942 std::map<int, std::string> m;
949 std::map<int, std::string> m = {{1,
"one"}, {2,
"two"}, {3,
"three"}};
953 auto it = list.get_it();
963 std::map<std::string, int> m = {{
"a", 1}, {
"b", 2}};
975 std::map<std::string, int> m = {{
"x", 10}, {
"y", 20}, {
"z", 30}};
979 auto it = keys.get_it();
989 std::map<std::string, int> m = {{
"a", 100}, {
"b", 200}};
993 auto it = values.get_it();
1013 for (
auto it = list.get_it(); it.has_curr(); it.next_ne())
1064 auto it = dlist.get_it();
1075 auto it = list.get_it();
1099 auto it = list.get_it();
1173 std::vector<std::string>
vec = {
"a",
"b",
"a",
"c"};
1212 for (
size_t i = 0; i < arr.size(); ++i)
1229 for (
size_t i = 0; i < arr.size(); ++i)
1270 auto it = list.get_it();
1278 EXPECT_EQ(it.get_curr().second,
"three");
1317 auto it = keys.get_it();
1334 auto it = values.get_it();
1342 std::map<std::string, int>
stdmap = {{
"a", 1}, {
"b", 2}, {
"c", 3}};
1363 std::map<std::string, int> check;
1364 list.for_each([&check](
const auto & p) { check[p.first] = p.second; });
1378 std::map<int, std::string> check;
1379 for (
size_t i = 0; i < arr.size(); ++i)
1380 check[arr(i).first] = arr(i).second;
1431 std::vector<int>
vec;
1438 std::vector<int>
vec = {42};
1447 std::vector<int>
vec = {5, 2, 8, 2, 1, 8, 3};
1460 std::vector<std::string>
vec = {
"cat",
"dog",
"cat",
"bird",
"dog"};
1472 std::vector<int>
original = {7, 3, 9, 3, 1};
1602 auto it = list.get_it();
Conversion utilities between Aleph-w and STL container types.
Simple dynamic array with automatic resizing and functional operations.
T & append(const T &data)
Append a copy of data
T & append()
Allocate a new entry to the end of array.
Dynamic doubly linked list with O(1) size and bidirectional access.
T & append(const T &item)
Append a copied item at the end of the list.
Key * insert(const Key &key)
Inserts key into the hash set.
Dynamic singly linked list with functional programming support.
T & insert(const T &item)
Insert a new item by copy.
T & append(const T &item)
Append a new item by copy.
void empty() noexcept
empty the list
Generic key-value map implemented on top of a binary search tree.
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair.
Dynamic set backed by balanced binary search trees with automatic memory management.
Key * insert(const Key &key)
Inserts a key into the dynamic set.
bool contains(const Key &key) const
size_t size() const noexcept
Count the number of elements of the list.
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
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.
DynSetTree< T > vector_to_DynSetTree(const std::vector< T > &v)
Convert a std::vector to a DynSetTree.
std::set< Key > settree_to_stdset(const DynSetTree< Key, Tree, Compare > &s)
Convert a DynSetTree to a std::set.
DynList< T > to_DynList(const Array< T > &a)
Convert an Array to a DynList.
DynList< K > map_keys_to_DynList(const std::map< K, V, Compare, Alloc > &m)
Extract keys from a std::map to a DynList.
DynList< V > map_values_to_DynList(const std::map< K, V, Compare, Alloc > &m)
Extract values from a std::map to a DynList.
DynList< std::pair< K, V > > map_to_DynList(const std::map< K, V, Compare, Alloc > &m)
Convert a std::map to a DynList of pairs.
DynList< T > dyndlist_to_DynList(const DynDlist< T > &l)
Convert a DynDlist to a DynList.
DynList< T > dynarray_to_DynList(const DynArray< T > &a)
Convert a DynArray to a DynList.
DynList< Key > maptree_keys_to_DynList(const DynMapTree< Key, Data, Tree, Compare > &m)
Extract keys from a DynMapTree to a DynList.
DynArray< T > dyndlist_to_DynArray(const DynDlist< T > &l)
Convert a DynDlist to a DynArray.
Array< std::pair< Key, Data > > maphash_to_Array(const MapOpenHash< Key, Data, Cmp, HashTable > &m)
Convert a MapOpenHash to an Array of pairs.
DynList< std::pair< Key, Data > > maphash_to_DynList(const MapOpenHash< Key, Data, Cmp, HashTable > &m)
Convert a MapOpenHash to a DynList of pairs.
Array< std::pair< Key, Data > > maptree_to_Array(const DynMapTree< Key, Data, Tree, Compare > &m)
Convert a DynMapTree to an Array of pairs.
DynDlist< T > vector_to_DynDlist(const std::vector< T > &v)
Convert a std::vector to a DynDlist.
Array< T > deque_to_Array(const std::deque< T > &d)
Convert a std::deque to an Array.
Array< T > init_to_Array(std::initializer_list< T > il)
Convert an initializer_list to an Array.
std::vector< Key > sethash_to_vector(const DynHashTable< Key, HashTable, Cmp > &s)
Convert a DynHashTable (hash set) to a std::vector.
DynList< std::pair< Key, Data > > maptree_to_DynList(const DynMapTree< Key, Data, Tree, Compare > &m)
Convert a DynMapTree to a DynList of pairs.
Array< T > dynarray_to_Array(const DynArray< T > &a)
Convert a DynArray to an Array.
DynList< Data > maptree_values_to_DynList(const DynMapTree< Key, Data, Tree, Compare > &m)
Extract values from a DynMapTree to a DynList.
DynArray< Key > settree_to_DynArray(const DynSetTree< Key, Tree, Compare > &s)
Convert a DynSetTree to a DynArray.
std::map< Key, Data > maphash_to_stdmap(const MapOpenHash< Key, Data, Cmp, HashTable > &m)
Convert a MapOpenHash to a std::map.
Array< T > set_to_Array(const std::set< T, Compare, Alloc > &s)
Convert a std::set to an Array.
DynList< T > vector_to_DynList(const std::vector< T > &v)
Convert a std::vector to a DynList.
DynArray< T > dynlist_to_DynArray(const DynList< T > &l)
Convert a DynList to a DynArray.
DynArray< T > array_to_DynArray(const Array< T > &a)
Convert an Array to a DynArray.
DynSetTree< typename C::Item_Type > to_DynSetTree(const C &c)
Convert a container to a DynSetTree (AVL by default).
DynArray< T > deque_to_DynArray(const std::deque< T > &d)
Convert a std::deque to a DynArray.
std::vector< Key > settree_to_vector(const DynSetTree< Key, Tree, Compare > &s)
Convert a DynSetTree to a std::vector.
std::set< typename C::Item_Type > to_set(const C &c)
Convert a container to a std::set.
Array< T > vector_to_Array(const std::vector< T > &v)
Convert a std::vector to an Array.
DynList< Key > sethash_to_DynList(const DynHashTable< Key, HashTable, Cmp > &s)
Convert a DynHashTable (hash set) to a DynList.
Array< typename C::Item_Type > to_Array(const C &c)
Convert a container to an Array.
DynDlist< T > dynlist_to_DynDlist(const DynList< T > &l)
Convert a DynList to a DynDlist.
Array< Key > sethash_to_Array(const DynHashTable< Key, HashTable, Cmp > &s)
Convert a DynHashTable (hash set) to an Array.
DynList< Data > maphash_values_to_DynList(const MapOpenHash< Key, Data, Cmp, HashTable > &m)
Extract values from a MapOpenHash to a DynList.
DynList< Key > settree_to_DynList(const DynSetTree< Key, Tree, Compare > &s)
Convert a DynSetTree to a DynList.
std::map< Key, Data > maptree_to_stdmap(const DynMapTree< Key, Data, Tree, Compare > &m)
Convert a DynMapTree to a std::map.
DynArray< T > vector_to_DynArray(const std::vector< T > &v)
Convert a std::vector to a DynArray.
DynList< T > deque_to_DynList(const std::deque< T > &d)
Convert a std::deque to a DynList.
Array< std::pair< K, V > > map_to_Array(const std::map< K, V, Compare, Alloc > &m)
Convert a std::map to an Array of pairs.
DynList< Key > maphash_keys_to_DynList(const MapOpenHash< Key, Data, Cmp, HashTable > &m)
Extract keys from a MapOpenHash to a DynList.
DynList< T > set_to_DynList(const std::set< T, Compare, Alloc > &s)
Convert a std::set to a DynList.
DynMapTree< K, V > stdmap_to_DynMapTree(const std::map< K, V, Compare, Alloc > &m)
Convert a std::map to a DynMapTree.
DynArray< T > set_to_DynArray(const std::set< T, Compare, Alloc > &s)
Convert a std::set to a DynArray.
Array< Key > settree_to_Array(const DynSetTree< Key, Tree, Compare > &s)
Convert a DynSetTree to an Array.
std::vector< typename C::Item_Type > to_vector(const C &c)
Convert a container to a std::vector.
DynArray< Key > sethash_to_DynArray(const DynHashTable< Key, HashTable, Cmp > &s)
Convert a DynHashTable (hash set) to a DynArray.
std::deque< typename C::Item_Type > to_deque(const C &c)
Convert a container to a std::deque.
DynArray< typename C::Item_Type > to_DynArray(const C &c)
Convert a container to a DynArray.
DynList< T > maps(const C &c, Op op)
Classic map operation.
DynDlist< T > dynarray_to_DynDlist(const DynArray< T > &a)
Convert a DynArray to a DynDlist.
DynList< T > init_to_DynList(std::initializer_list< T > il)
Convert an initializer_list to a DynList.
DynArray< T > init_to_DynArray(std::initializer_list< T > il)
Convert an initializer_list to a DynArray.
Open addressing hash map using double hashing.
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair (copy semantics).