6#include <gtest/gtest.h>
30static_assert(AlephSequence<DynList<int>>
and AlephSequence<DynDlist<int>>);
31static_assert(AlephSequence<Array<int>>
and AlephSequence<DynArray<int>>);
32static_assert(AlephIterableContainer<DynMapTree<int, int>>
and not AlephSequence<DynMapTree<int, int>>);
33static_assert(AlephTraversable<FlatSet<int>>
and not AlephIterableContainer<FlatSet<int>>);
34static_assert(AlephIterator<DynList<int>::Iterator>);
41 struct Items_Of_Dnodes :
Dnode<int>::Iterator
48static_assert(AlephUncheckedIterator<DynList<int>::Iterator>
49 and AlephUncheckedIterator<DynDlist<int>::Iterator>
50 and AlephUncheckedIterator<Array<int>::Iterator>
51 and AlephUncheckedIterator<Dnode<int>::Iterator>);
52static_assert(AlephIterator<Items_Of_Dnodes>
53 and not AlephUncheckedIterator<Items_Of_Dnodes>);
56static_assert(AlephIterator<Slist<int>::Iterator>
and AlephIterator<DynSlist<int>::Iterator>);
58 std::declval<std::vector<int> &>()))>);
59static_assert(AlephIterator<
decltype(
stl_zip_it(std::declval<std::vector<int> &>(),
60 std::declval<std::list<int> &>()))>);
61static_assert(AlephIterator<StlEnumerateIterator<std::vector<int>>>);
66static_assert(AlephIterable<DynList<int>>
and AlephIterable<DynSetTree<int>>);
67static_assert(AlephIterable<MemArray<int>>
and AlephIterable<LhashTable<int>>);
68static_assert(not AlephIterable<std::vector<int>>
and not AlephIterable<FlatSet<int>>);
69static_assert(not AlephTraversable<std::vector<int>>
and not AlephIterator<int>);
71static_assert(StlIterableContainer<std::vector<int>>
and StlIterableContainer<std::map<int, int>>);
74static_assert(not StlIterableContainer<DynList<int>>);
76namespace U = uni_functional_detail;
77namespace Z = uni_zip_detail;
78namespace F = stl_detail;
91TEST(AhContainerConceptsTest, HierarchyHoldsForLiveContainers)
94 static_assert(AlephSequence<
decltype(
l)>);
96 for (
auto it =
l.
get_it(); it.has_curr(); it.next_ne())
98 EXPECT_EQ(n,
l.
size());
102TEST(AhContainerConceptsTest, UniFunctionalIteratesContainersWithoutGetIt)
105 for (
int i : {1, 2, 3})
114TEST(AhContainerConceptsTest, ZipIteratesChainedHashTables)
120 for (
auto it =
uni_zip_it(
l, t); it.has_curr(); it.next())
122 auto [x, bucket] = it.get_curr();
124 EXPECT_EQ(bucket->get_key(), 7);
133 template <AlephIterator It>
134 size_t count_with_next_ne(
It it)
143TEST(AhContainerConceptsTest, NextNeMatchesNextOnSlistIterators)
146 for (
int i = 0; i < 4; ++i)
154 EXPECT_EQ(by_next, by_next_ne);
162TEST(AhContainerConceptsTest, ZipAdaptorsWorkInGenericIteratorCode)
165 std::vector<int> b = {4, 5};
166 std::list<int> c = {6, 7, 8};
168 EXPECT_EQ(count_with_next_ne(
uni_zip_it(a, b)), 2u);
169 EXPECT_EQ(count_with_next_ne(
stl_zip_it(b, c)), 2u);
Functional programming utilities for C++ Standard Library containers.
Lazy zip iterators and functional operations for STL containers.
Unified functional programming utilities for both STL and Aleph containers.
Unified zip operations for both STL and Aleph containers.
size_t size_t int32_t value
Dnode< T > * get_curr() const
Return a pointer to the current node.
Node belonging to a double circular linked list with header node.
T & get_data() noexcept
Return a modifiable reference to the data contained in the node.
T & get_curr() const
Return the current item.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
T & insert(const T &item)
size_t size() const noexcept
Return the number of items of the list, in constant time.
Iterator specialized for DynSlist returning payload references.
Dynamic list of elements of type T implemented with a singly linked list of nodes.
void next()
Advances the iterator to the next filtered element.
void next_ne() noexcept(shows_ne)
Advances the iterator to the next filtered element, as next() does.
Bucket * insert(Bucket *bucket)
Inserts bucket into the table and returns its address if the key is not already in the table; otherwi...
bool has_curr() const noexcept
Simple, scalable and fast dynamic array.
Iterator over singly linked nodes.
Iterator that pairs each element with its index.
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
Key * append(const Key &key)
Alias for insert() (copy version).
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
constexpr auto stl_zip_it(const Containers &... cs)
Get a zip iterator over STL containers.
auto get_curr() const
Return the current tuple (bounds-checked).
and
Check uniqueness with explicit hash + equality functors.
void uni_for_each(Op &&op, const Container &c)
Apply operation to each element (for_each).
auto uni_zip_it(const Containers &...cs)
Get a unified zip iterator.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
Generic hash table with collision resolution by separate chaining and buckets without virtual destruc...
Detect if a container has reverse iterators.
Detect if a type has a size() method.
Detect if a type is hashable via std::hash.
Trait to detect if a type has an Aleph-style Iterator interface.
Trait to detect if a type has an STL-style iterator interface (begin/end).
FooMap m(5, fst_unit_pair_hash, snd_unit_pair_hash)
Dynamic array container with automatic resizing.
Lazy and scalable dynamic array implementation.
Dynamic doubly linked list implementation.
Dynamic key-value map based on balanced binary search trees.
Dynamic set implementations based on balanced binary search trees.
Dynamic singly linked list.
Sorted-array set (Aleph::FlatSet), a cache-friendly ordered set.
Hash tables with collision resolution by separate chaining.
Simple, scalable, contiguous dynamic array.