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

Random queue. More...

#include <tpl_random_queue.H>

Inheritance diagram for Aleph::Random_Set< T >:
[legend]
Collaboration diagram for Aleph::Random_Set< T >:
[legend]

Classes

struct  Iterator
 Iterator of the items of the queue. More...
 

Public Types

using Set_Type = Random_Set
 
using Item_Type = T
 The type of set.
 
using Const_Iterator = Aleph::Const_Iterator< Iterator >
 Read-only iterator: the iterator of a constant container.
 
- Public Types inherited from StlAlephIterator< Random_Set< T > >
using iterator = StlIterator< Random_Set< T > >
 
using const_iterator = StlConstIterator< Random_Set< T > >
 

Public Member Functions

Random_Source & random_source () noexcept
 The type of data contained in the queue.
 
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 () const
 The Mersenne Twister of the set, which a set that was given no seed makes here, and draws from it from then on.
 
void set_seed (unsigned long seed) const
 Seeds the Mersenne Twister of the set, as gsl_rng_set() did: the positions are from then on those of GSL for the seed.
 
size_t size () const
 Return the number of items in the queue.
 
 Random_Set ()
 A random queue that draws its positions from a SplitMix64 with a seed of its own.
 
void swap (Random_Set &s) noexcept(noexcept(array.swap(s.array)))
 Swap in constant time this with s: their items and their generators.
 
 Random_Set (const Random_Set &s)
 Copy constructor.
 
 Random_Set (Random_Set &&s) noexcept(std::is_nothrow_move_constructible_v< DynArray< T > >)
 Take the items and the generator of another set, which is left empty, and draws from then on from a SplitMix64 with a seed of its own.
 
Random_Set & operator= (const Random_Set &s)
 
Random_Set & operator= (Random_Set &&s) noexcept(noexcept(swap(s)))
 Exchange this set with another, which is left with the items and the generator that this one had.
 
 Random_Set (const DynList< T > &l)
 Initialize the random queue with the elements of l
 
template<class It >
 Random_Set (It b, It e)
 Initialize the random queue with the items between b and e where these parameters are stl iterators.
 
 Random_Set (std::initializer_list< T > l)
 Initialize the random queue with the items of l
 
void put (const T &item)
 Insert an item by copy.
 
void put (T &&item)
 Insert an item by moving.
 
T & append (const T &item)
 Insert randomly an item by copy.
 
T & append (T &&item)
 Insert randomly an item by moving.
 
T get ()
 Extract randomly an item.
 
T pick () const
 
bool is_empty () const
 Return true if the queue is empty.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &operation) noexcept(noexcept(array.traverse(operation)))
 Conditional traversing of the random queue.
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &operation) const noexcept(noexcept(array.traverse(operation)))
 See traverse(Operation & operation).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool traverse (Operation &&operation=Operation()) const noexcept(noexcept(array.traverse(operation)))
 See traverse(Operation & operation).
 
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool traverse (Operation &&operation=Operation()) noexcept(noexcept(array.traverse(operation)))
 See traverse(Operation & operation).
 
- Public Member Functions inherited from LocateFunctions< Random_Set< T >, T >
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().
 
T & nth_ne (const size_t n) noexcept(Aleph::dry_detail::mutable_traversal_is_noexcept< C, T >)
 Return the n‑th element without bounds checking.
 
const T & nth_ne (const size_t n) const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Random_Set< T >, T >)
 Constant overload of nth_ne(size_t).
 
T & nth (const size_t n)
 Return the n-th item of the container.
 
const T & nth (const size_t n) const
 Const overload of nth(size_t).
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Random_Set< T >, Operation >::type, T > T * find_ptr (Operation &operation) noexcept(mutable_search_is_noexcept< Operation >())
 Find a pointer to an item in the container according to a searching criterion.
 
const T * find_ptr (Operation &operation) const noexcept(const_search_is_noexcept< Operation >())
 Const overload of find_ptr(Operation&).
 
const T * find_ptr (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
 Overload of find_ptr() const that accepts rvalues.
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Random_Set< T >, Operation >::type, T > T * find_ptr (Operation &&operation) noexcept(mutable_search_is_noexcept< Operation >())
 Overload of find_ptr() that accepts rvalues.
 
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.
 
size_t find_index (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
 Overload of find_index() that accepts rvalues.
 
and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, T > find_item (Operation &operation) const noexcept(find_item_is_noexcept< Operation >())
 Safe sequential searching of an item matching a criterion.
 
and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, T > find_item (Operation &&operation) const noexcept(find_item_is_noexcept< Operation >())
 Overload of find_item() that accepts rvalues.
 
and std::copy_constructible< T > std::optional< T > find_opt (Operation &operation) const
 Copy of the first item satisfying a criterion, if any.
 
and std::copy_constructible< T > std::optional< T > find_opt (Operation &&operation) const
 Overload of find_opt() that accepts rvalues.
 
bool contains_if (Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
 Test if an item satisfying a criterion is present in the container.
 
bool contains (const T &item) const
 Test if an item is present in the container using equality.
 
- Public Member Functions inherited from FunctionalMethods< Random_Set< T >, 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)
 
size_t ninsert (Args &&... args)
 Insert n variadic items.
 
size_t nappend (Args &&... args)
 Append n variadic items.
 
void for_each (Operation &operation) const
 Traverse all the container and performs an operation on each element.
 
void for_each (Operation &&operation) const
 Overload of for_each() that accepts rvalues.
 
void each (Operation &operation) const
 Alias of for_each().
 
void each (Operation &&operation) const
 Alias of for_each() that accepts rvalues.
 
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.
 
void each (const size_t pos, const size_t slice, Operation &&operation) const
 See each(size_t pos, size_t slice, Operation & operation) const.
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Random_Set< T >, 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.
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Random_Set< T >, 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).
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Random_Set< T >, Operation >::type, T > void mutable_for_each (Operation &operation)
 Apply a mutable operation to each element of the container.
 
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Random_Set< T >, Operation >::type, T > void mutable_for_each (Operation &&operation)
 See mutable_for_each(Operation & operation).
 
bool all (Operation &operation) const
 Check if all the elements of the container satisfy a condition.
 
bool all (Operation &&operation) const
 Overload of all() that accepts rvalues.
 
bool exists (Operation &op) const
 Test for existence in the container of an element satisfying a criterion.
 
bool exists (Operation &&op) const
 Overload of exists() that accepts rvalues.
 
bool none (Operation &op) const
 Test that no element satisfies a criterion.
 
bool none (Operation &&op) const
 Overload of none() that accepts rvalues.
 
size_t count_if (Operation &op) const
 Count the elements that satisfy a criterion.
 
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
 
auto flat_map (Operation &op) const
 Map each element to a container and concatenate the results.
 
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.
 
Acc foldl (const Acc &init, Op &op) const
 Fold the elements of the container to a specific result.
 
Acc foldl (const Acc &init, Op &&op) const
 Overload of foldl() that accepts rvalues.
 
Acc fold_left (const Acc &init, Op &op) const
 Alias for foldl().
 
Acc fold_left (const Acc &init, Op &&op) const
 Overload of fold_left() that accepts rvalues.
 
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.
 
T fold (const T &init, Operation &&operation) const
 Overload of fold() that accepts rvalues.
 
Acc foldr (const Acc &init, Op &op) const
 Fold the elements from the last to the first.
 
Acc foldr (const Acc &init, Op &&op) const
 Overload of foldr() that accepts rvalues.
 
and std::copy_constructible< U > std::optional< T > reduce (Op &op) const
 Fold the elements with no initial value.
 
and std::copy_constructible< U > std::optional< T > reduce (Op &&op) const
 Overload of reduce() that accepts rvalues.
 
Aleph::DynList< T > filter (Operation &operation) const
 Filter the elements of a container according to a matching criterion.
 
Aleph::DynList< T > filter (Operation &&operation) const
 Overload of filter() that accepts rvalues.
 
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.
 
Aleph::DynList< const T * > ptr_filter (Operation &&operation) const
 Overload of ptr_filter() that accepts rvalues.
 
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.
 
Aleph::DynList< std::tuple< T, size_t > > pfilter (Operation &&operation) const
 Overload of pfilter() that accepts rvalues.
 
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition (Operation &op) const
 Exclusive partition of container according to a filter criterion.
 
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.
 
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition (Operation &op) const
 Exclusive partition of container according to a filter criterion.
 
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< Random_Set< T >, 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.
 
Aleph::DynList< T > take_while (Operation &op) const
 The longest prefix of elements that satisfy a criterion.
 
Aleph::DynList< T > take_while (Operation &&op) const
 Overload of take_while() that accepts rvalues.
 
Aleph::DynList< T > drop_while (Operation &op) const
 The elements after the longest prefix that satisfies a criterion.
 
Aleph::DynList< T > drop_while (Operation &&op) const
 Overload of drop_while() that accepts rvalues.
 
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< Random_Set< T > >
iterator begin () noexcept
 Return an STL-compatible iterator to the first element.
 
const_iterator begin () const noexcept
 Return a const iterator to the first element.
 
iterator end () noexcept
 Return an STL-compatible end iterator.
 
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.
 

Private Attributes

DynArray< T > array
 
Random_Source r
 

Additional Inherited Members

- Static Public Member Functions inherited from FunctionalMethods< Random_Set< T >, T >
static Random_Set< T > build (Items &&... items)
 Build a container that holds the given items.
 
static D build_as (Items &&... items)
 Build a D, a class derived from the container, holding the given items.
 
- Public Attributes inherited from FunctionalMethods< Random_Set< T >, T >
 and
 Insert a new element into the container by constructing it from the given args.
 
and Aleph::InvocableWith< Operation &, const T & > and
 Conditional mapping of the elements of the container.
 

Detailed Description

template<class T>
class Aleph::Random_Set< T >

Random queue.

Random_Set<T> implements a random set of items which are inserted and extracted in a random order.

The positions come from a Random_Source: by default, from a SplitMix64 inside the set, with a seed of its own; after 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 order is the same. random_source() gives the source, which can be asked for a SplitMix64 with a seed.

Note
The move constructor is noexcept when the items are built by default and swapped without throwing, as an int: it builds the default value of the array that it leaves to the source, an item built by default, and allocates no directory. With other items, a growing std::vector copies these objects instead of moving them, since it 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 80 of file tpl_random_queue.H.

Member Typedef Documentation

◆ Const_Iterator

Read-only iterator: the iterator of a constant container.

Definition at line 366 of file tpl_random_queue.H.

◆ Item_Type

template<class T >
using Aleph::Random_Set< T >::Item_Type = T

The type of set.

Definition at line 95 of file tpl_random_queue.H.

◆ Set_Type

template<class T >
using Aleph::Random_Set< T >::Set_Type = Random_Set

Definition at line 93 of file tpl_random_queue.H.

Constructor & Destructor Documentation

◆ Random_Set() [1/6]

template<class T >
Aleph::Random_Set< T >::Random_Set ( )
inline

A random queue that draws its positions from a SplitMix64 with a seed of its own.

Definition at line 152 of file tpl_random_queue.H.

◆ Random_Set() [2/6]

template<class T >
Aleph::Random_Set< T >::Random_Set ( const Random_Set< T > &  s)
inline

Copy constructor.

Definition at line 174 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::append(), and FunctionalMethods< Container, T >::for_each().

◆ Random_Set() [3/6]

template<class T >
Aleph::Random_Set< T >::Random_Set ( Random_Set< T > &&  s)
inlinenoexcept

Take the items and the generator of another set, which is left empty, and draws from then on from a SplitMix64 with a seed of its own.

Parameters
[in,out]sthe set to move from.
Exceptions
whatthe move of its array throws: the default construction of an item, for the default value of the array, or the swap of two items; then s is unchanged, if that swap left its arguments as they were. Nothing with an item that is built by default and swapped without throwing.
Note
It allocates no directory: the array left to s makes its directory when it first writes. It builds its default value, an item built by default, which may allocate, as an Array.

Definition at line 193 of file tpl_random_queue.H.

◆ Random_Set() [4/6]

template<class T >
Aleph::Random_Set< T >::Random_Set ( const DynList< T > &  l)
inline

Initialize the random queue with the elements of l

Definition at line 228 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::append(), FunctionalMethods< Container, T >::for_each(), and l.

◆ Random_Set() [5/6]

template<class T >
template<class It >
Aleph::Random_Set< T >::Random_Set ( It  b,
It  e 
)
inline

Initialize the random queue with the items between b and e where these parameters are stl iterators.

Definition at line 235 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::append().

◆ Random_Set() [6/6]

template<class T >
Aleph::Random_Set< T >::Random_Set ( std::initializer_list< T >  l)
inline

Initialize the random queue with the items of l

Definition at line 242 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::append(), and l.

Member Function Documentation

◆ append() [1/2]

template<class T >
T & Aleph::Random_Set< T >::append ( const T &  item)
inline

Insert randomly an item by copy.

append(item) performs a random choice. Use this method if you must obtain fastly a random array. It returns a reference to the stored element so callers can mutate it in place, same as other Aleph sequences.

Parameters
[in]itemreference to the item to be inserted
Returns
reference to the inserted item inside the queue
Exceptions
bad_allocif there is no enough memory

Definition at line 292 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::array, Aleph::Random_Set< T >::put(), Aleph::Random_Set< T >::r, and Aleph::Random_Source::uniform_int_ne().

Referenced by Aleph::Random_Set< T >::Random_Set(), Aleph::Random_Set< T >::Random_Set(), Aleph::Random_Set< T >::Random_Set(), Aleph::Random_Set< T >::Random_Set(), Moved_From_Case< Random_Set< int > >::make(), Aleph::Random_Set< T >::operator=(), TEST(), TEST(), TEST(), TEST(), TEST(), and Moved_From_Case< Random_Set< int > >::use().

◆ append() [2/2]

template<class T >
T & Aleph::Random_Set< T >::append ( T &&  item)
inline

Insert randomly an item by moving.

Parameters
[in]itemrvalue reference to the item to be inserted
Returns
reference to the inserted item inside the queue
Exceptions
bad_allocif there is no enough memory

Definition at line 308 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::array, Aleph::Random_Set< T >::put(), Aleph::Random_Set< T >::r, and Aleph::Random_Source::uniform_int_ne().

◆ get()

◆ is_empty()

template<class T >
bool Aleph::Random_Set< T >::is_empty ( ) const
inline

Return true if the queue is empty.

Definition at line 340 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::array.

Referenced by Moved_From_Case< Random_Set< int > >::is_empty(), Aleph::shuffle(), Aleph::shuffle_ptr(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ operator=() [1/2]

template<class T >
Random_Set & Aleph::Random_Set< T >::operator= ( const Random_Set< T > &  s)
inline

◆ operator=() [2/2]

template<class T >
Random_Set & Aleph::Random_Set< T >::operator= ( Random_Set< T > &&  s)
inlinenoexcept

Exchange this set with another, which is left with the items and the generator that this one had.

Parameters
[in,out]sthe set to move from.
Returns
*this.
Exceptions
whatswap() throws: the swap of two items, with an item whose swap may throw, as one that has no move and is copied. It was declared noexcept without a condition, and such a swap that threw, or that had no memory, ended the program.

Definition at line 221 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::swap().

◆ pick()

◆ put() [1/2]

template<class T >
void Aleph::Random_Set< T >::put ( const T &  item)
inline

Insert an item by copy.

put() does not perform any random operation. It simply puts the item at the end of an internal sequence. It is when the item is extracted that a random choice is done.

Parameters
[in]itemreference to the item to be inserted
Exceptions
bad_allocif there is no enough memory

Definition at line 257 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::array.

Referenced by Aleph::Random_Set< T >::append(), Aleph::Random_Set< T >::append(), Aleph::shuffle(), Aleph::shuffle_ptr(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), and Moved_From_Case< Random_Set< int > >::use().

◆ put() [2/2]

template<class T >
void Aleph::Random_Set< T >::put ( T &&  item)
inline

Insert an item by moving.

put() does not perform any random operation. It simply puts the item at the end of an internal sequence. It is when the item is extracted that a random choice is done.

Parameters
[in]itemrvalue reference to the item to be moved
Exceptions
bad_allocif there is no enough memory

Definition at line 274 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::array.

◆ random_source() [1/2]

template<class T >
const Random_Source & Aleph::Random_Set< T >::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 102 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::r.

◆ random_source() [2/2]

template<class T >
Random_Source & Aleph::Random_Set< T >::random_source ( )
inlinenoexcept

The type of data contained in the queue.

The source of random numbers, which draws the positions.

Definition at line 98 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::r.

◆ rng()

template<class T >
Gsl_Compatible_Rng & Aleph::Random_Set< T >::rng ( ) const
inline

The Mersenne Twister of the set, which a set 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 set 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 set has no Mersenne Twister and there is not enough memory for it.
Note
It changes a constant set that has no Mersenne Twister, as get_rng() and set_seed() do: none of them may run at the same time as another use of the set.

Definition at line 118 of file tpl_random_queue.H.

References Aleph::Random_Source::mersenne_twister(), and Aleph::Random_Set< T >::r.

Referenced by TEST().

◆ set_seed()

template<class T >
void Aleph::Random_Set< T >::set_seed ( unsigned long  seed) const
inline

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

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

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

Definition at line 142 of file tpl_random_queue.H.

References Aleph::Random_Source::Mersenne_Twister, Aleph::Random_Set< T >::r, Aleph::Random_Source::seed(), and seed.

Referenced by Moved_From_Case< Random_Set< int > >::make(), Aleph::random_preflow_maximum_flow(), TEST(), TEST(), and TEST().

◆ size()

template<class T >
size_t Aleph::Random_Set< T >::size ( ) const
inline

Return the number of items in the queue.

Definition at line 148 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::array.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), and Moved_From_Case< Random_Set< int > >::use().

◆ swap()

template<class T >
void Aleph::Random_Set< T >::swap ( Random_Set< T > &  s)
inlinenoexcept

Swap in constant time this with s: their items and their generators.

Parameters
[in,out]sthe set to swap with.
Exceptions
whatswapping two items throws, which the arrays do for their default values; then nothing is exchanged, if that swap left its arguments as they were. Nothing with an item whose swap cannot throw.

Definition at line 167 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::array, Aleph::Random_Set< T >::r, and Aleph::Random_Source::swap().

Referenced by Aleph::Random_Set< T >::operator=(), and TEST().

◆ traverse() [1/4]

template<class T >
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool Aleph::Random_Set< T >::traverse ( Operation &&  operation = Operation()) const
inlinenoexcept

See traverse(Operation & operation).

Definition at line 393 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::traverse().

◆ traverse() [2/4]

template<class T >
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool Aleph::Random_Set< T >::traverse ( Operation &&  operation = Operation())
inlinenoexcept

See traverse(Operation & operation).

Definition at line 402 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::traverse().

◆ traverse() [3/4]

template<class T >
template<class Operation >
requires Aleph::PredicateWith<Operation &, const T &>
bool Aleph::Random_Set< T >::traverse ( Operation &  operation) const
inlinenoexcept

See traverse(Operation & operation).

Definition at line 384 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::array.

◆ traverse() [4/4]

template<class T >
template<class Operation >
requires Aleph::PredicateWith<Operation &, T &>
bool Aleph::Random_Set< T >::traverse ( Operation &  operation)
inlinenoexcept

Conditional traversing of the random queue.

Parameters
[in]operationto be performed on each item. If it return true then the traversing continues; otherwise stops.

Definition at line 375 of file tpl_random_queue.H.

References Aleph::Random_Set< T >::array.

Referenced by TEST(), TEST(), TEST(), Aleph::Random_Set< T >::traverse(), and Aleph::Random_Set< T >::traverse().

Member Data Documentation

◆ array

◆ r


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