Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::DynSkipList< Key, Compare > Class Template Reference

Dynamic ordered set implemented with a Skip List. More...

#include <tpl_dynSkipList.H>

Inheritance diagram for Aleph::DynSkipList< Key, Compare >:
[legend]
Collaboration diagram for Aleph::DynSkipList< Key, Compare >:
[legend]

Classes

class  Iterator
 Forward iterator for DynSkipList. More...
 
struct  Node
 Internal node structure. More...
 

Public Types

using Set_Type = DynSkipList
 The type of container.
 
using Item_Type = Key
 The type of element that stores the container.
 
using Key_Type = Key
 The type of element that stores the container.
 
- Public Types inherited from StlAlephIterator< SetName >
using iterator = StlIterator< SetName >
 
using const_iterator = StlConstIterator< SetName >
 

Public Member Functions

void set_seed (unsigned long seed)
 Seeds the Mersenne Twister of the list, as gsl_rng_set() did: the levels are from then on those of GSL for the seed.
 
Random_Source & random_source () noexcept
 The source of random numbers, which draws the levels.
 
const Random_Source & random_source () const noexcept
 The source of random numbers, to look at it: its engine, or whether it is equal to another one.
 
Gsl_Compatible_Rng & rng ()
 The Mersenne Twister of the list, which a list that was given no seed makes here, and draws from it from then on.
 
 DynSkipList (unsigned long seed, double p=defaultProbability)
 Construct a DynSkipList with given seed and probability, whose levels are those of GSL for the seed: it draws them from a Mersenne Twister, in dynamic memory.
 
 DynSkipList (double p=defaultProbability)
 Construct a DynSkipList that draws its levels from a SplitMix64 with a seed of its own.
 
template<template< typename > class List>
 DynSkipList (const List< Key > &l)
 
template<class It >
requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; })
 DynSkipList (It b, It e)
 
 DynSkipList (std::initializer_list< Key > l)
 
 DynSkipList (const DynSkipList &other)
 Copy constructor: the copy draws the levels of its nodes from a SplitMix64 with a seed of its own, whatever the generator of the list that it copies.
 
 DynSkipList (DynSkipList &&other)
 Move constructor: take the nodes, the generator and the comparison criterion of another list, which is left empty, and draws from then on from a SplitMix64 with a seed of its own, as a copy does.
 
 ~DynSkipList ()
 Destructor - frees all nodes and the random number generator.
 
DynSkipList & operator= (const DynSkipList &other)
 Copy assignment operator.
 
DynSkipList & operator= (DynSkipList &&other) noexcept(noexcept(swap(other)))
 Move assignment: free the nodes of this list, and exchange it with another, which is left empty with the generator of this one.
 
void swap (DynSkipList &other) noexcept(std::is_nothrow_swappable_v< Compare >)
 Swap contents with another DynSkipList.
 
void empty () noexcept
 Remove all elements from the set.
 
void clear () noexcept
 Empties the container.
 
size_t size () const noexcept
 Return the number of elements in the set.
 
bool is_empty () const noexcept
 Return true if the set is empty.
 
Compare & get_compare () noexcept
 Get the comparison functor.
 
const Compare & get_compare () const noexcept
 Get the comparison functor (const version)
 
Key * insert (const Key &key)
 Insert an element into the set.
 
Key * insert (Key &&key)
 Insert an element into the set (move version).
 
Key & insert_unique (const Key &key)
 Insert an element, throwing if it already exists.
 
Key & append (const Key &key)
 Append method for Special_Ctors compatibility (aliases to insert)
 
Key & append (Key &&key)
 See append(const Key & key).
 
Key * search_or_insert (const Key &key)
 Search and insert if not found.
 
const Key * search (const Key &key) const noexcept
 Search for a key in the set.
 
Key * search (const Key &key) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The same key, modifiable.
 
bool has (const Key &key) const noexcept
 Return true if the key exists in the set.
 
bool contains (const Key &key) const noexcept
 Checks if a key exists in the set.
 
bool exist (const Key &key) const noexcept
 Alias for has()
 
Key & find (const Key &key)
 Find a key, throwing if not found.
 
const Key & find (const Key &key) const
 Const version of find()
 
size_t remove (const Key &key)
 Remove a key from the set.
 
Key del (const Key &key)
 Remove and return a key.
 
const Key & min () const
 Return the minimum element (first in sorted order)
 
const Key & get_first () const
 Alias for min()
 
const Key & max () const
 Return the maximum element (last in sorted order)
 
const Key & get_last () const
 Alias for max()
 
DynSkipList join (const DynSkipList &other) const
 Compute the union of two sets.
 
DynSkipList intersect (const DynSkipList &other) const
 Compute the intersection of two sets.
 
DynSkipList diff (const DynSkipList &other) const
 Compute the difference of two sets.
 
Iterator begin () const noexcept
 
Iterator end () const noexcept
 
Iterator get_it () const noexcept
 Alias for begin() - for generic programming.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool traverse (Operation &op) const noexcept(Aleph::NothrowPredicateWith< Operation &, const Key & >)
 Traverse the keys in increasing order.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool traverse (Operation &&op=Operation()) const noexcept(Aleph::NothrowPredicateWith< Operation &, const Key & >)
 See traverse(Operation & op) const.
 
- Public Member Functions inherited from GenericTraverse< Container >
template<class Operation >
requires Aleph::PredicateWith<Operation &, typename Aleph::concepts_detail::traverse_arg<Container, Operation>::type>
bool traverse (Operation &operation) noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_arg< Container, Operation >::type, Container & >())
 Traverse the container via its iterator and performs a conditioned operation on each item.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, typename Aleph::concepts_detail::traverse_carg<Container, Operation>::type>
bool traverse (Operation &operation) const noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_carg< Container, Operation >::type, const_source_t< Operation > >())
 Traverse a constant container; each item is handed out as a constant reference.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, typename Aleph::concepts_detail::traverse_carg<Container, Operation>::type>
bool traverse (Operation &&operation) const noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_carg< Container, Operation >::type, const_source_t< Operation > >())
 Overload of traverse(Operation &) const that accepts rvalues.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, typename Aleph::concepts_detail::traverse_arg<Container, Operation>::type>
bool traverse (Operation &&operation) noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_arg< Container, Operation >::type, Container & >())
 Overload of traverse(Operation &) that accepts rvalues.
 
- Public Member Functions inherited from SpecialCtors< Container, T >
 SpecialCtors ()=default
 Default constructor; it appends nothing.
 
 SpecialCtors (const SpecialCtors &)=default
 Copy constructor; the derived container copies its items.
 
 SpecialCtors (SpecialCtors &&) noexcept
 Move constructor; the derived container moves its items.
 
SpecialCtors & operator= (const SpecialCtors &)=default
 Copy assignment; the derived container copies its items.
 
SpecialCtors & operator= (SpecialCtors &&) noexcept
 Move assignment; the derived container moves its items.
 
 SpecialCtors (const Aleph::DynList< T > &l)
 Build the container by inserting all items of the list l.
 
template<class It >
requires (not std::is_arithmetic_v<It> and requires(It it) { *it; ++it; it != it; })
 SpecialCtors (It b, It e)
 Construct the container from a range of iterators.
 
 SpecialCtors (std::initializer_list< T > l)
 Construct the container from an initializer list.
 
- Public Member Functions inherited from LocateFunctions< Container, Type >
auto get_it ()
 Return a properly initialized iterator positioned at the first item on the container.
 
auto get_it () const
 Read-only iterator positioned at the first item.
 
auto get_it (const size_t pos)
 Return a properly initialized iterator positioned at the pos item on the container.
 
auto get_it (const size_t pos) const
 Read-only iterator positioned at the pos item.
 
auto get_itor ()
 Alias of get_it().
 
auto get_itor () const
 See get_itor().
 
template<class C = Container>
requires Aleph::dry_detail::MutablyTraversable<C, Type>
Type & nth_ne (const size_t n) noexcept(Aleph::dry_detail::mutable_traversal_is_noexcept< C, Type >)
 Return the n‑th element without bounds checking.
 
const Type & nth_ne (const size_t n) const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Container, Type >)
 Constant overload of nth_ne(size_t).
 
template<class C = Container>
requires Aleph::dry_detail::MutablyTraversable<C, Type>
Type & nth (const size_t n)
 Return the n-th item of the container.
 
const Type & nth (const size_t n) const
 Const overload of nth(size_t).
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, Type &>
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, Type > Type * find_ptr (Operation &operation) noexcept(mutable_search_is_noexcept< Operation >())
 Find a pointer to an item in the container according to a searching criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const Type &>
const Type * find_ptr (Operation &operation) const noexcept(const_search_is_noexcept< Operation >())
 Const overload of find_ptr(Operation&).
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const Type &>
const Type * find_ptr (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
 Overload of find_ptr() const that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, Type &>
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, Type > Type * find_ptr (Operation &&operation) noexcept(mutable_search_is_noexcept< Operation >())
 Overload of find_ptr() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const Type &>
size_t find_index (Operation &operation) const noexcept(const_search_is_noexcept< Operation >())
 Find the position of an item in the container according to a searching criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const Type &>
size_t find_index (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
 Overload of find_index() that accepts rvalues.
 
template<class Operation , class T = Type>
requires Aleph::InvocablePredicateWith<Operation &, const Type &>
and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, Type > find_item (Operation &operation) const noexcept(find_item_is_noexcept< Operation >())
 Safe sequential searching of an item matching a criterion.
 
template<class Operation , class T = Type>
requires Aleph::InvocablePredicateWith<Operation &, const Type &>
and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, Type > find_item (Operation &&operation) const noexcept(find_item_is_noexcept< Operation >())
 Overload of find_item() that accepts rvalues.
 
template<class Operation , class T = Type>
requires Aleph::InvocablePredicateWith<Operation &, const Type &>
and std::copy_constructible< T > std::optional< Type > find_opt (Operation &operation) const
 Copy of the first item satisfying a criterion, if any.
 
template<class Operation , class T = Type>
requires Aleph::InvocablePredicateWith<Operation &, const Type &>
and std::copy_constructible< T > std::optional< Type > find_opt (Operation &&operation) const
 Overload of find_opt() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const Type &>
bool contains_if (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
 Test if an item satisfying a criterion is present in the container.
 
template<class T = Type>
requires requires(const T & a, const T & b) { { a == b } -> std::convertible_to<bool>; }
bool contains (const Type &item) const
 Test if an item is present in the container using equality.
 
- Public Member Functions inherited from FunctionalMethods< Container, T >
void emplace (Args &&... args)
 Appends a new element into the container by constructing it from the given args.
 
void emplace_end (Args &&... args)
 See emplace(Args && ... args).
 
void emplace_ins (Args &&... args)
 
template<typename... Args>
requires ((std::convertible_to<Args &&, T> and ...) and (Aleph::InsertableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type, Item_Arg<Args>> and ...))
size_t ninsert (Args &&... args)
 Insert n variadic items.
 
template<typename... Args>
requires ((std::convertible_to<Args &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type, Item_Arg<Args>> and ...))
size_t nappend (Args &&... args)
 Append n variadic items.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void for_each (Operation &operation) const
 Traverse all the container and performs an operation on each element.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void for_each (Operation &&operation) const
 Overload of for_each() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (Operation &operation) const
 Alias of for_each().
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (Operation &&operation) const
 Alias of for_each() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (const size_t pos, const size_t slice, Operation &operation) const
 Traverse the container starting at pos taking one item every slice, performing an operation on each visited element.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
void each (const size_t pos, const size_t slice, Operation &&operation) const
 See each(size_t pos, size_t slice, Operation & operation) const.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void each (const size_t pos, const size_t slice, Operation &operation)
 Traverse the container starting at pos taking one item every slice, performing an operation that may modify each visited item.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void each (const size_t pos, const size_t slice, Operation &&operation)
 See each(size_t pos, size_t slice, Operation & operation).
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void mutable_for_each (Operation &operation)
 Apply a mutable operation to each element of the container.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, T &>
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void mutable_for_each (Operation &&operation)
 See mutable_for_each(Operation & operation).
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool all (Operation &operation) const
 Check if all the elements of the container satisfy a condition.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool all (Operation &&operation) const
 Overload of all() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool exists (Operation &op) const
 Test for existence in the container of an element satisfying a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool exists (Operation &&op) const
 Overload of exists() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool none (Operation &op) const
 Test that no element satisfies a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
bool none (Operation &&op) const
 Overload of none() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
size_t count_if (Operation &op) const
 Count the elements that satisfy a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
size_t count_if (Operation &&op) const
 Overload of count_if() that accepts rvalues.
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps (Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps (Operation &&op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps_if (Prop prop, Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps_if (Prop prop, Operation &&op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map (Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map (Operation &&op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map_if (Prop prop, Operation &op) const
 
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map_if (Prop prop, Operation &&op) const
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
auto flat_map (Operation &op) const
 Map each element to a container and concatenate the results.
 
template<class Operation >
requires Aleph::InvocableWith<Operation &, const T &>
auto flat_map (Operation &&op) const
 Overload of flat_map() that accepts rvalues.
 
Aleph::DynList< T > to_dynlist () const
 Convert container to DynList.
 
std::vector< T > to_vector () const
 Convert container to std::vector.
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldOperation<Op, Acc, T>
Acc foldl (const Acc &init, Op &op) const
 Fold the elements of the container to a specific result.
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldOperation<Op, Acc, T>
Acc foldl (const Acc &init, Op &&op) const
 Overload of foldl() that accepts rvalues.
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldOperation<Op, Acc, T>
Acc fold_left (const Acc &init, Op &op) const
 Alias for foldl().
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldOperation<Op, Acc, T>
Acc fold_left (const Acc &init, Op &&op) const
 Overload of fold_left() that accepts rvalues.
 
template<class Operation >
requires Aleph::dry_detail::FoldOperation<Operation, T, T>
T fold (const T &init, Operation &operation) const
 Simplified version of foldl() where the folded type is the same type of elements stored in the container.
 
template<class Operation >
requires Aleph::dry_detail::FoldOperation<Operation, T, T>
T fold (const T &init, Operation &&operation) const
 Overload of fold() that accepts rvalues.
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldRightOperation<Op, Acc, T>
Acc foldr (const Acc &init, Op &op) const
 Fold the elements from the last to the first.
 
template<typename Acc = T, class Op >
requires Aleph::dry_detail::FoldRightOperation<Op, Acc, T>
Acc foldr (const Acc &init, Op &&op) const
 Overload of foldr() that accepts rvalues.
 
template<class Op , class U = T>
requires Aleph::dry_detail::FoldOperation<Op, T, T>
and std::copy_constructible< U > std::optional< T > reduce (Op &op) const
 Fold the elements with no initial value.
 
template<class Op , class U = T>
requires Aleph::dry_detail::FoldOperation<Op, T, T>
and std::copy_constructible< U > std::optional< T > reduce (Op &&op) const
 Overload of reduce() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > filter (Operation &operation) const
 Filter the elements of a container according to a matching criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > filter (Operation &&operation) const
 Overload of filter() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< const T * > ptr_filter (Operation &operation) const
 Filter the elements of a container according to a matching criterion and return a pointer to the matched items in the container.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< const T * > ptr_filter (Operation &&operation) const
 Overload of ptr_filter() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &operation) const
 Filter the elements of a container according to a matching criterion and determine its positions respect to the traversal of container.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &&operation) const
 Overload of pfilter() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &op) const
 Exclusive partition of container according to a filter criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &&op) const
 Overload of partition() that accepts rvalues.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (size_t n) const
 Exclusive partition of container in the nth item.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > split_half () const
 Split the container into two halves by alternating elements.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition (Operation &op) const
 Exclusive partition of container according to a filter criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition (Operation &&op) const
 Overload of tpartition() that accepts rvalues.
 
size_t length () const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Container, T >)
 Count the number of elements of a container.
 
Aleph::DynList< T > rev () const
 Return a list with the elements of container in reverse order respect to its traversal order.
 
Aleph::DynList< T > take (const size_t n) const
 Return a list with the first n elements seen in the container during its traversal.
 
Aleph::DynList< T > take (size_t i, const size_t j, const size_t step=1) const
 Return a list with the elements at positions i, i + step, i + 2 step, ... that are not greater than j, respect to the traversal order.
 
Aleph::DynList< T > drop (const size_t n) const
 Drop the first n elements seen in the container during its traversal.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > take_while (Operation &op) const
 The longest prefix of elements that satisfy a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > take_while (Operation &&op) const
 Overload of take_while() that accepts rvalues.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > drop_while (Operation &op) const
 The elements after the longest prefix that satisfies a criterion.
 
template<class Operation >
requires Aleph::InvocablePredicateWith<Operation &, const T &>
Aleph::DynList< T > drop_while (Operation &&op) const
 Overload of drop_while() that accepts rvalues.
 
template<class C = Container>
requires requires (C & c) { c.remove(); }
void mutable_drop (const size_t n)
 Drop the first n elements seen from container.
 
- Public Member Functions inherited from GenericItems< Container, T >
Aleph::DynList< T > items () const
 Return a list of all the elements of a container sorted by traversal order.
 
Aleph::DynList< T > keys () const
 See items().
 
- Public Member Functions inherited from StlAlephIterator< SetName >
iterator begin () noexcept
 Return an STL-compatible iterator to the first element.
 
iterator end () noexcept
 Return an STL-compatible end iterator.
 
const_iterator begin () const noexcept
 Return a const iterator to the first element.
 
const_iterator end () const noexcept
 Return a const end iterator.
 
const_iterator cbegin () const noexcept
 Return a const iterator to the first element.
 
const_iterator cend () const noexcept
 Return a const end iterator.
 

Static Public Attributes

static constexpr int maxLevel = 32
 Maximum number of levels (supports up to 2^32 elements efficiently)
 
static constexpr double defaultProbability = 0.5
 Default probability for level generation (0.5 = geometric distribution)
 

Private Member Functions

int random_level () const noexcept
 
bool keys_equal (const Key &k1, const Key &k2) const noexcept
 
 DynSkipList (const double p, const Compare &c)
 
 DynSkipList (const double p, Compare &&c)
 
void swap_but_comparison (DynSkipList &other) noexcept
 

Static Private Member Functions

static unsigned long generator_seed (const unsigned long seed) noexcept
 
static decltype(auto) comparison_to_take (Compare &c) noexcept
 

Private Attributes

Node * header
 
Random_Source r
 
size_t num_nodes = 0
 
int current_level = 1
 
double probability
 
Compare cmp
 

Additional Inherited Members

- Static Public Member Functions inherited from FunctionalMethods< Container, T >
template<typename... Items>
requires ((std::convertible_to<Items &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<Items...>>::type, Item_Arg<Items>> and ...))
static Container build (Items &&... items)
 Build a container that holds the given items.
 
template<class D , typename... Items>
requires (std::derived_from<D, typename Aleph::concepts_detail::defer<Container, D>::type> and std::default_initializable<D> and (std::convertible_to<Items &&, T> and ...) and (Aleph::AppendableWith<typename Aleph::concepts_detail::defer<Container, std::tuple<D, Items...>>::type, Item_Arg<Items>> and ...))
static D build_as (Items &&... items)
 Build a D, a class derived from the container, holding the given items.
 
- Public Attributes inherited from FunctionalMethods< Container, T >
template<typename... Args>
requires (typename Aleph::concepts_detail::defer<Container, std::tuple<Args...>>::type & c, T && x)
 and { c.append(std::move(x))
 Insert a new element into the container by constructing it from the given args.
 
template<typename R = void, class Prop , class Operation >
requires (Aleph::DynList<Aleph::dry_detail::map_result_t<R, Operation &, T>> & l, Operation & op, const T & item)
and Aleph::InvocableWith< Operation &, const T & > and { l.append(std::invoke(op, item))
 Conditional mapping of the elements of the container.
 

Detailed Description

template<typename Key, class Compare = std::less<Key>>
class Aleph::DynSkipList< Key, Compare >

Dynamic ordered set implemented with a Skip List.

DynSkipList<Key, Compare> is a dynamic set that automatically manages memory for its elements. It uses a Skip List as the underlying data structure, providing expected O(log n) time for search, insert, and delete operations.

The levels come from a Random_Source: by default, from a SplitMix64 inside the list, with a seed of its own; with a seed, that of a constructor or of set_seed(), from a Gsl_Compatible_Rng, the Mersenne twister with the numbers of the one of GSL - GNU Scientific Library, which it used before: for a seed, the levels are the same. random_source() gives the source, which can be asked for a SplitMix64 with a seed.

Template Parameters
KeyType of elements stored in the set.
CompareComparison functor (default: std::less<Key>).
Complexity
  • Search: O(log n) expected
  • Insert: O(log n) expected
  • Delete: O(log n) expected
  • Min/Max: O(1) / O(n)
  • size(): O(1)
See also
DynSetTree DynSetHash
Note
A growing std::vector copies these objects instead of moving them: their move constructor is not noexcept, because it leaves the source empty and usable, which allocates its header, and std::vector moves only what cannot throw. The containers of Aleph do not copy them to grow: Array moves its items, and DynList and DynArray never relocate them.

Definition at line 122 of file tpl_dynSkipList.H.

Member Typedef Documentation

◆ Item_Type

template<typename Key , class Compare = std::less<Key>>
using Aleph::DynSkipList< Key, Compare >::Item_Type = Key

The type of element that stores the container.

Definition at line 136 of file tpl_dynSkipList.H.

◆ Key_Type

template<typename Key , class Compare = std::less<Key>>
using Aleph::DynSkipList< Key, Compare >::Key_Type = Key

The type of element that stores the container.

Definition at line 139 of file tpl_dynSkipList.H.

◆ Set_Type

template<typename Key , class Compare = std::less<Key>>
using Aleph::DynSkipList< Key, Compare >::Set_Type = DynSkipList

The type of container.

Definition at line 133 of file tpl_dynSkipList.H.

Constructor & Destructor Documentation

◆ DynSkipList() [1/9]

template<typename Key , class Compare = std::less<Key>>
Aleph::DynSkipList< Key, Compare >::DynSkipList ( const double  p,
const Compare &  c 
)
inlineprivate

◆ DynSkipList() [2/9]

template<typename Key , class Compare = std::less<Key>>
Aleph::DynSkipList< Key, Compare >::DynSkipList ( const double  p,
Compare &&  c 
)
inlineprivate

◆ DynSkipList() [3/9]

template<typename Key , class Compare = std::less<Key>>
Aleph::DynSkipList< Key, Compare >::DynSkipList ( unsigned long  seed,
double  p = defaultProbability 
)
inline

Construct a DynSkipList with given seed and probability, whose levels are those of GSL for the seed: it draws them from a Mersenne Twister, in dynamic memory.

Parameters
[in]seedRandom seed for level generation, taken modulo 2^32 - 1, as it was for GSL.
[in]pProbability for level increase (default 0.5); it must be strictly between 0 and 1.
Exceptions
domain_errorif p is not in (0, 1): with p >= 1 every node would get the maximum level, and with p <= 0 every node level 1; in both cases searches degrade to linear time.
bad_allocif there is not enough memory.

Definition at line 308 of file tpl_dynSkipList.H.

References ah_domain_error_if, FunctionalMethods< Container, T >::and, Aleph::DynSkipList< Key, Compare >::header, and Aleph::DynSkipList< Key, Compare >::maxLevel.

◆ DynSkipList() [4/9]

template<typename Key , class Compare = std::less<Key>>
Aleph::DynSkipList< Key, Compare >::DynSkipList ( double  p = defaultProbability)
inlineexplicit

Construct a DynSkipList that draws its levels from a SplitMix64 with a seed of its own.

Parameters
[in]pProbability for level increase (default 0.5); it must be strictly between 0 and 1.
Exceptions
domain_errorif p is not in (0, 1), as the constructor with a seed.
bad_allocif there is not enough memory for the header.

Definition at line 324 of file tpl_dynSkipList.H.

References ah_domain_error_if, FunctionalMethods< Container, T >::and, Aleph::DynSkipList< Key, Compare >::header, and Aleph::DynSkipList< Key, Compare >::maxLevel.

◆ DynSkipList() [5/9]

template<typename Key , class Compare = std::less<Key>>
template<template< typename > class List>
Aleph::DynSkipList< Key, Compare >::DynSkipList ( const List< Key > &  l)
inline

Definition at line 332 of file tpl_dynSkipList.H.

◆ DynSkipList() [6/9]

template<typename Key , class Compare = std::less<Key>>
template<class It >
requires (not std::is_arithmetic_v<It> and requires (It it) { *it; ++it; it != it; })
Aleph::DynSkipList< Key, Compare >::DynSkipList ( It  b,
It  e 
)
inline

Definition at line 332 of file tpl_dynSkipList.H.

◆ DynSkipList() [7/9]

template<typename Key , class Compare = std::less<Key>>
Aleph::DynSkipList< Key, Compare >::DynSkipList ( std::initializer_list< Key >  l)
inline

Definition at line 332 of file tpl_dynSkipList.H.

◆ DynSkipList() [8/9]

template<typename Key , class Compare = std::less<Key>>
Aleph::DynSkipList< Key, Compare >::DynSkipList ( const DynSkipList< Key, Compare > &  other)
inline

Copy constructor: the copy draws the levels of its nodes from a SplitMix64 with a seed of its own, whatever the generator of the list that it copies.

Parameters
[in]otherthe list to copy.
Exceptions
bad_allocif there is not enough memory, or what the copy of a key throws; then the copy frees what it took.

Definition at line 341 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::begin(), Aleph::DynSkipList< Key, Compare >::empty(), Aleph::DynSkipList< Key, Compare >::header, Aleph::DynSkipList< Key, Compare >::insert(), and Aleph::DynSkipList< Key, Compare >::maxLevel.

◆ DynSkipList() [9/9]

template<typename Key , class Compare = std::less<Key>>
Aleph::DynSkipList< Key, Compare >::DynSkipList ( DynSkipList< Key, Compare > &&  other)
inline

Move constructor: take the nodes, the generator and the comparison criterion of another list, which is left empty, and draws from then on from a SplitMix64 with a seed of its own, as a copy does.

The comparison criterion is copied, if it can be copied, so that other keeps its own; else it is moved, and other is left with one moved from.

Parameters
[in,out]otherthe list to move from.
Exceptions
bad_allocif there is not enough memory for the header left to other, or what the copy or the move of the comparison criterion throws; then other is unchanged, but for a comparison criterion that was moved.
Note
It allocates the header left to other, and no generator.

Definition at line 382 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::swap_but_comparison().

◆ ~DynSkipList()

template<typename Key , class Compare = std::less<Key>>
Aleph::DynSkipList< Key, Compare >::~DynSkipList ( )
inline

Destructor - frees all nodes and the random number generator.

Definition at line 391 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::empty(), and Aleph::DynSkipList< Key, Compare >::header.

Member Function Documentation

◆ append() [1/2]

template<typename Key , class Compare = std::less<Key>>
Key & Aleph::DynSkipList< Key, Compare >::append ( const Key &  key)
inline

Append method for Special_Ctors compatibility (aliases to insert)

Definition at line 599 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::insert(), and Aleph::DynSkipList< Key, Compare >::search().

◆ append() [2/2]

template<typename Key , class Compare = std::less<Key>>
Key & Aleph::DynSkipList< Key, Compare >::append ( Key &&  key)
inline

See append(const Key & key).

Definition at line 608 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::insert(), and Aleph::DynSkipList< Key, Compare >::search().

◆ begin()

◆ clear()

template<typename Key , class Compare = std::less<Key>>
void Aleph::DynSkipList< Key, Compare >::clear ( )
inlinenoexcept

Empties the container.

Exceptions
none
See also
empty()

Definition at line 477 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::empty().

◆ comparison_to_take()

template<typename Key , class Compare = std::less<Key>>
static decltype(auto) Aleph::DynSkipList< Key, Compare >::comparison_to_take ( Compare &  c)
inlinestaticprivatenoexcept

Definition at line 229 of file tpl_dynSkipList.H.

◆ contains()

template<typename Key , class Compare = std::less<Key>>
bool Aleph::DynSkipList< Key, Compare >::contains ( const Key &  key) const
inlinenoexcept

Checks if a key exists in the set.

Parameters
[in]keykey to search for.
Returns
true if key is present, false otherwise.
Exceptions
none

Definition at line 672 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::has().

◆ del()

template<typename Key , class Compare = std::less<Key>>
Key Aleph::DynSkipList< Key, Compare >::del ( const Key &  key)
inline

◆ diff()

template<typename Key , class Compare = std::less<Key>>
DynSkipList Aleph::DynSkipList< Key, Compare >::diff ( const DynSkipList< Key, Compare > &  other) const
inline

Compute the difference of two sets.

Parameters
[in]otherThe other set.
Returns
A new set containing elements in this but not in other.

Definition at line 839 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::begin(), Aleph::DynSkipList< Key, Compare >::has(), Aleph::DynSkipList< Key, Compare >::Iterator::has_curr(), and Aleph::DynSkipList< Key, Compare >::insert().

◆ empty()

◆ end()

template<typename Key , class Compare = std::less<Key>>
Iterator Aleph::DynSkipList< Key, Compare >::end ( ) const
inlinenoexcept

Definition at line 940 of file tpl_dynSkipList.H.

◆ exist()

template<typename Key , class Compare = std::less<Key>>
bool Aleph::DynSkipList< Key, Compare >::exist ( const Key &  key) const
inlinenoexcept

Alias for has()

Definition at line 675 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::has().

◆ find() [1/2]

template<typename Key , class Compare = std::less<Key>>
Key & Aleph::DynSkipList< Key, Compare >::find ( const Key &  key)
inline

Find a key, throwing if not found.

Parameters
[in]keyThe key to find.
Returns
Reference to the key.
Exceptions
std::domain_errorIf the key is not found.

Definition at line 683 of file tpl_dynSkipList.H.

References ah_domain_error_if, and Aleph::DynSkipList< Key, Compare >::search().

◆ find() [2/2]

template<typename Key , class Compare = std::less<Key>>
const Key & Aleph::DynSkipList< Key, Compare >::find ( const Key &  key) const
inline

Const version of find()

Definition at line 692 of file tpl_dynSkipList.H.

References ah_domain_error_if, and Aleph::DynSkipList< Key, Compare >::search().

◆ generator_seed()

template<typename Key , class Compare = std::less<Key>>
static unsigned long Aleph::DynSkipList< Key, Compare >::generator_seed ( const unsigned long  seed)
inlinestaticprivatenoexcept

Definition at line 192 of file tpl_dynSkipList.H.

References Aleph::Gsl_Compatible_Rng::max(), and seed.

◆ get_compare() [1/2]

template<typename Key , class Compare = std::less<Key>>
const Compare & Aleph::DynSkipList< Key, Compare >::get_compare ( ) const
inlinenoexcept

Get the comparison functor (const version)

Definition at line 489 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::cmp.

◆ get_compare() [2/2]

template<typename Key , class Compare = std::less<Key>>
Compare & Aleph::DynSkipList< Key, Compare >::get_compare ( )
inlinenoexcept

Get the comparison functor.

Definition at line 486 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::cmp.

◆ get_first()

template<typename Key , class Compare = std::less<Key>>
const Key & Aleph::DynSkipList< Key, Compare >::get_first ( ) const
inline

Alias for min()

Definition at line 787 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::min().

◆ get_it()

template<typename Key , class Compare = std::less<Key>>
Iterator Aleph::DynSkipList< Key, Compare >::get_it ( ) const
inlinenoexcept

Alias for begin() - for generic programming.

Definition at line 943 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::begin().

Referenced by demonstrate_basic_operations(), and demonstrate_string_set().

◆ get_last()

template<typename Key , class Compare = std::less<Key>>
const Key & Aleph::DynSkipList< Key, Compare >::get_last ( ) const
inline

Alias for max()

Definition at line 801 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::max().

◆ has()

template<typename Key , class Compare = std::less<Key>>
bool Aleph::DynSkipList< Key, Compare >::has ( const Key &  key) const
inlinenoexcept

◆ insert() [1/2]

template<typename Key , class Compare = std::less<Key>>
Key * Aleph::DynSkipList< Key, Compare >::insert ( const Key &  key)
inline

◆ insert() [2/2]

template<typename Key , class Compare = std::less<Key>>
Key * Aleph::DynSkipList< Key, Compare >::insert ( Key &&  key)
inline

◆ insert_unique()

template<typename Key , class Compare = std::less<Key>>
Key & Aleph::DynSkipList< Key, Compare >::insert_unique ( const Key &  key)
inline

Insert an element, throwing if it already exists.

Parameters
[in]keyThe key to insert.
Returns
Reference to the inserted key.
Exceptions
std::domain_errorIf the key already exists.
std::bad_allocIf memory allocation fails.

Definition at line 590 of file tpl_dynSkipList.H.

References ah_domain_error_if, and Aleph::DynSkipList< Key, Compare >::insert().

◆ intersect()

template<typename Key , class Compare = std::less<Key>>
DynSkipList Aleph::DynSkipList< Key, Compare >::intersect ( const DynSkipList< Key, Compare > &  other) const
inline

Compute the intersection of two sets.

Parameters
[in]otherThe other set.
Returns
A new set containing elements present in both sets.

Definition at line 825 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::begin(), Aleph::DynSkipList< Key, Compare >::has(), Aleph::DynSkipList< Key, Compare >::Iterator::has_curr(), and Aleph::DynSkipList< Key, Compare >::insert().

◆ is_empty()

template<typename Key , class Compare = std::less<Key>>
bool Aleph::DynSkipList< Key, Compare >::is_empty ( ) const
inlinenoexcept

◆ join()

template<typename Key , class Compare = std::less<Key>>
DynSkipList Aleph::DynSkipList< Key, Compare >::join ( const DynSkipList< Key, Compare > &  other) const
inline

Compute the union of two sets.

Parameters
[in]otherThe other set.
Returns
A new set containing all elements from both sets.

Definition at line 812 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::begin(), and Aleph::DynSkipList< Key, Compare >::insert().

◆ keys_equal()

template<typename Key , class Compare = std::less<Key>>
bool Aleph::DynSkipList< Key, Compare >::keys_equal ( const Key &  k1,
const Key &  k2 
) const
inlineprivatenoexcept

◆ max()

template<typename Key , class Compare = std::less<Key>>
const Key & Aleph::DynSkipList< Key, Compare >::max ( ) const
inline

◆ min()

template<typename Key , class Compare = std::less<Key>>
const Key & Aleph::DynSkipList< Key, Compare >::min ( ) const
inline

◆ operator=() [1/2]

template<typename Key , class Compare = std::less<Key>>
DynSkipList & Aleph::DynSkipList< Key, Compare >::operator= ( const DynSkipList< Key, Compare > &  other)
inline

◆ operator=() [2/2]

template<typename Key , class Compare = std::less<Key>>
DynSkipList & Aleph::DynSkipList< Key, Compare >::operator= ( DynSkipList< Key, Compare > &&  other)
inlinenoexcept

Move assignment: free the nodes of this list, and exchange it with another, which is left empty with the generator of this one.

The previous assignment took the generator of other, which then drew levels from a null one. The nodes of this list are freed, as they were, so that other is left empty.

Parameters
[in,out]otherthe list to move from.
Returns
a reference to this list.
Exceptions
whatswapping the comparisons throws; then this list is left empty, and other keeps its nodes.
Note
O(n), for the nodes of this list.

Definition at line 428 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::empty(), and Aleph::DynSkipList< Key, Compare >::swap().

◆ random_level()

◆ random_source() [1/2]

template<typename Key , class Compare = std::less<Key>>
const Random_Source & Aleph::DynSkipList< Key, Compare >::random_source ( ) const
inlinenoexcept

The source of random numbers, to look at it: its engine, or whether it is equal to another one.

Definition at line 268 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::r.

◆ random_source() [2/2]

template<typename Key , class Compare = std::less<Key>>
Random_Source & Aleph::DynSkipList< Key, Compare >::random_source ( )
inlinenoexcept

The source of random numbers, which draws the levels.

Definition at line 264 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::r.

◆ remove()

◆ rng()

template<typename Key , class Compare = std::less<Key>>
Gsl_Compatible_Rng & Aleph::DynSkipList< Key, Compare >::rng ( )
inline

The Mersenne Twister of the list, which a list that was given no seed makes here, and draws from it from then on.

Deprecated:
It makes a generator of some 2500 bytes in a list that has none; use random_source(). It goes in 8.0.0.
Returns
The Mersenne Twister: Random_Source::mersenne_twister().
Exceptions
std::bad_allocIf the list has no Mersenne Twister and there is not enough memory for it.

Definition at line 281 of file tpl_dynSkipList.H.

References Aleph::Random_Source::mersenne_twister(), and Aleph::DynSkipList< Key, Compare >::r.

Referenced by TEST().

◆ search() [1/2]

◆ search() [2/2]

template<typename Key , class Compare = std::less<Key>>
Key * Aleph::DynSkipList< Key, Compare >::search ( const Key &  key)
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The same key, modifiable.

Definition at line 655 of file tpl_dynSkipList.H.

◆ search_or_insert()

template<typename Key , class Compare = std::less<Key>>
Key * Aleph::DynSkipList< Key, Compare >::search_or_insert ( const Key &  key)
inline

Search and insert if not found.

Parameters
[in]keyThe key to search/insert.
Returns
Pointer to existing or newly inserted key.

Definition at line 624 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::insert(), and Aleph::DynSkipList< Key, Compare >::search().

◆ set_seed()

template<typename Key , class Compare = std::less<Key>>
void Aleph::DynSkipList< Key, Compare >::set_seed ( unsigned long  seed)
inline

Seeds the Mersenne Twister of the list, as gsl_rng_set() did: the levels are from then on those of GSL for the seed.

A list that was given no seed makes its Mersenne Twister here.

Parameters
[in]seedThe seed.
Exceptions
std::bad_allocIf the list has no Mersenne Twister and there is not enough memory for it; then it is unchanged.

Definition at line 258 of file tpl_dynSkipList.H.

References Aleph::Random_Source::Mersenne_Twister, Aleph::DynSkipList< Key, Compare >::r, Aleph::Random_Source::seed(), and seed.

◆ size()

template<typename Key , class Compare = std::less<Key>>
size_t Aleph::DynSkipList< Key, Compare >::size ( ) const
inlinenoexcept

Return the number of elements in the set.

Definition at line 480 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::num_nodes.

Referenced by benchmark_comparison(), and demonstrate_basic_operations().

◆ swap()

template<typename Key , class Compare = std::less<Key>>
void Aleph::DynSkipList< Key, Compare >::swap ( DynSkipList< Key, Compare > &  other)
inlinenoexcept

Swap contents with another DynSkipList.

Parameters
[in,out]otherthe list to exchange with.
Exceptions
whatswapping the comparisons throws. They are exchanged first, so that, if that swap throws, nothing else is exchanged, and both lists are left as they were if it left its arguments as they were.

Definition at line 445 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::cmp, Aleph::DynSkipList< Key, Compare >::swap(), and Aleph::DynSkipList< Key, Compare >::swap_but_comparison().

Referenced by Aleph::DynSkipList< Key, Compare >::operator=(), and Aleph::DynSkipList< Key, Compare >::swap().

◆ swap_but_comparison()

◆ traverse() [1/2]

template<typename Key , class Compare = std::less<Key>>
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool Aleph::DynSkipList< Key, Compare >::traverse ( Operation &&  op = Operation()) const
inlinenoexcept

See traverse(Operation & op) const.

Definition at line 975 of file tpl_dynSkipList.H.

◆ traverse() [2/2]

template<typename Key , class Compare = std::less<Key>>
template<class Operation >
requires Aleph::PredicateWith<Operation &, const Key &>
bool Aleph::DynSkipList< Key, Compare >::traverse ( Operation &  op) const
inlinenoexcept

Traverse the keys in increasing order.

The keys of a skip list are kept sorted and must not be modified, so every traversal hands them out as constant references; the members inherited from FunctionalMethods (for_each(), all(), exists(), none(), foldl(), ...) are built on it.

Parameters
[in]opoperation with signature bool(const Key &); the traversal stops when it returns false.
Returns
true if all keys were visited; false otherwise.
Exceptions
anythingthat op throws.

Definition at line 963 of file tpl_dynSkipList.H.

References Aleph::DynSkipList< Key, Compare >::begin(), and Aleph::DynSkipList< Key, Compare >::Iterator::has_curr().

Member Data Documentation

◆ cmp

◆ current_level

◆ defaultProbability

template<typename Key , class Compare = std::less<Key>>
constexpr double Aleph::DynSkipList< Key, Compare >::defaultProbability = 0.5
staticconstexpr

Default probability for level generation (0.5 = geometric distribution)

Definition at line 145 of file tpl_dynSkipList.H.

◆ header

◆ maxLevel

◆ num_nodes

◆ probability

template<typename Key , class Compare = std::less<Key>>
double Aleph::DynSkipList< Key, Compare >::probability
private

◆ r


The documentation for this class was generated from the following file: