C++ Library Extensions 2022.12.09
To help learn modern C++ programming
cpg::chrono_random Namespace Reference

Implements random number generator and stop watch. More...

Classes

class  fair_dice
 
class  random_t
 
class  random_words
 
class  stop_watch
 

Typedefs

using nano_t = std::nano
 
using micro_t = std::micro
 
using milli_t = std::milli
 
using second_t = std::ratio< 1 >
 
using minute_t = std::ratio< 60 >
 
using hour_t = std::ratio< 3600 >
 
template<typename TimeUnit >
using duration_t = std::chrono::duration< double, TimeUnit >
 
using nanoseconds_t = duration_t< nano_t >
 
using microseconds_t = duration_t< micro_t >
 
using milliseconds_t = duration_t< milli_t >
 
using seconds_t = duration_t< second_t >
 
using minutes_t = duration_t< minute_t >
 
using hours_t = duration_t< hour_t >
 
using high_resolution_clock_t = std::chrono::high_resolution_clock
 
using time_point_t = std::chrono::time_point< high_resolution_clock_t >
 
using random_engine_t = std::default_random_engine
 
template<std::integral IntegralType>
using random_uniform_integral_distribution = std::uniform_int_distribution< IntegralType >
 
template<std::floating_point RealType>
using random_uniform_real_distribution = std::uniform_real_distribution< RealType >
 
template<std::integral IntegralType>
using random_uniform_integer_t = random_t< IntegralType, random_uniform_integral_distribution< IntegralType >, random_engine_t >
 
template<std::floating_point RealType>
using random_uniform_real_t = random_t< RealType, random_uniform_real_distribution< RealType >, random_engine_t >
 

Functions

unsigned int seed ()
 
unsigned int get_current_tick ()
 
template<typename TimeUnit >
double time_difference_in_unit (const time_point_t &start_time, const time_point_t &end_time)
 
template<typename ValueType , typename RangeType1 , typename RangeType2 >
auto random_generator (RangeType1 range_start, RangeType2 range_end)
 
template<typename Type , std::size_t N, typename RandomGeneratorType >
void random_fill (Type(&container)[N], RandomGeneratorType const &random_generator)
 
template<typename Type , std::size_t M, std::size_t N, typename RandomGeneratorType >
void random_fill (Type(&container)[M][N], RandomGeneratorType const &random_generator)
 
template<typename Type , std::size_t L, std::size_t M, std::size_t N, typename RandomGeneratorType >
void random_fill (Type(&container)[L][M][N], RandomGeneratorType const &random_generator)
 
template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RType , template< typename, typename... > class RandomGeneratorType, typename... RTypes>
void random_fill (ContainerType< Type, Types... > &container, const RandomGeneratorType< RType, RTypes... > &random_generator)
 
template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RandomGeneratorType >
void random_fill (ContainerType< Type, Types... > &container, RandomGeneratorType &&random_generator)
 
template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RangeType >
void random_fill (ContainerType< Type, Types... > &container, RangeType range_start, RangeType range_end)
 
template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RType , template< typename, typename... > class RandomGeneratorType, typename... RTypes>
void random_fill (ContainerType< Type, N > &container, const RandomGeneratorType< RType, RTypes... > &random_generator)
 
template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RandomGeneratorType >
void random_fill (ContainerType< Type, N > &container, RandomGeneratorType &&random_generator)
 
template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RangeType >
void random_fill (ContainerType< Type, N > &container, RangeType range_start, RangeType range_end)
 
template<typename Type , std::size_t N, template< typename, typename... > class RandomGeneratorType, typename RType , typename... RTypes>
void random_parallel_fill (Type(&container)[N], const RandomGeneratorType< RType, RTypes... > &random_generator)
 
template<typename Type , std::size_t M, std::size_t N, template< typename, typename... > class RandomGeneratorType, typename RType , typename... RTypes>
void random_parallel_fill (Type(&container)[M][N], const RandomGeneratorType< RType, RTypes... > &random_generator)
 
template<typename Type , std::size_t L, std::size_t M, std::size_t N, template< typename, typename... > class RandomGeneratorType, typename RType , typename... RTypes>
void random_parallel_fill (Type(&container)[L][M][N], const RandomGeneratorType< RType, RTypes... > &random_generator)
 
template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RType , template< typename, typename... > class RandomGeneratorType, typename... RTypes>
void random_parallel_fill (ContainerType< Type, Types... > &container, const RandomGeneratorType< RType, RTypes... > &random_generator)
 
template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RandomGeneratorType >
void random_parallel_fill (ContainerType< Type, Types... > &container, RandomGeneratorType &&random_generator)
 
template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RangeType >
void random_parallel_fill (ContainerType< Type, Types... > &container, RangeType range_start, RangeType range_end)
 
template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RType , template< typename, typename... > class RandomGeneratorType, typename... RTypes>
void random_parallel_fill (ContainerType< Type, N > &container, const RandomGeneratorType< RType, RTypes... > &random_generator)
 
template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RandomGeneratorType >
void random_parallel_fill (ContainerType< Type, N > &container, RandomGeneratorType &&random_generator)
 
template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RangeType >
void random_parallel_fill (ContainerType< Type, N > &container, RangeType range_start, RangeType range_end)
 
template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename SizeType , template< typename, typename... > class RandomGeneratorType, typename... RTypes>
void random_fill (ContainerType< Type, Types... > &container, const RandomGeneratorType< Type, RTypes... > &random_generator, SizeType size)
 Fills the /a container with random numbers. If the /a container is /a set or /a unordered_set, the range of the random_generator should be sufficiently big, otherwise it can fall into infinity loop.
More...
 
template<typename Type , size_t ArraySize>
 random_words (int, int, int, const Type(&)[ArraySize]) -> random_words< Type, ArraySize >
 

Variables

auto & now = high_resolution_clock_t::now
 

Detailed Description

Implements random number generator and stop watch.

Typedef Documentation

◆ duration_t

template<typename TimeUnit >
using cpg::chrono_random::duration_t = typedef std::chrono::duration<double, TimeUnit>

Definition at line 62 of file cpg_chrono_random.hpp.

◆ high_resolution_clock_t

using cpg::chrono_random::high_resolution_clock_t = typedef std::chrono::high_resolution_clock

Definition at line 71 of file cpg_chrono_random.hpp.

◆ hour_t

using cpg::chrono_random::hour_t = typedef std::ratio<3600>

Definition at line 59 of file cpg_chrono_random.hpp.

◆ hours_t

Definition at line 69 of file cpg_chrono_random.hpp.

◆ micro_t

using cpg::chrono_random::micro_t = typedef std::micro

Definition at line 55 of file cpg_chrono_random.hpp.

◆ microseconds_t

Definition at line 65 of file cpg_chrono_random.hpp.

◆ milli_t

using cpg::chrono_random::milli_t = typedef std::milli

Definition at line 56 of file cpg_chrono_random.hpp.

◆ milliseconds_t

Definition at line 66 of file cpg_chrono_random.hpp.

◆ minute_t

using cpg::chrono_random::minute_t = typedef std::ratio<60>

Definition at line 58 of file cpg_chrono_random.hpp.

◆ minutes_t

Definition at line 68 of file cpg_chrono_random.hpp.

◆ nano_t

using cpg::chrono_random::nano_t = typedef std::nano

Definition at line 54 of file cpg_chrono_random.hpp.

◆ nanoseconds_t

Definition at line 64 of file cpg_chrono_random.hpp.

◆ random_engine_t

using cpg::chrono_random::random_engine_t = typedef std::default_random_engine

Definition at line 114 of file cpg_chrono_random.hpp.

◆ random_uniform_integer_t

template<std::integral IntegralType>
using cpg::chrono_random::random_uniform_integer_t = typedef random_t<IntegralType, random_uniform_integral_distribution<IntegralType>, random_engine_t>

Definition at line 258 of file cpg_chrono_random.hpp.

◆ random_uniform_integral_distribution

template<std::integral IntegralType>
using cpg::chrono_random::random_uniform_integral_distribution = typedef std::uniform_int_distribution<IntegralType>

Definition at line 117 of file cpg_chrono_random.hpp.

◆ random_uniform_real_distribution

template<std::floating_point RealType>
using cpg::chrono_random::random_uniform_real_distribution = typedef std::uniform_real_distribution<RealType>

Definition at line 121 of file cpg_chrono_random.hpp.

◆ random_uniform_real_t

template<std::floating_point RealType>
using cpg::chrono_random::random_uniform_real_t = typedef random_t<RealType, random_uniform_real_distribution<RealType>, random_engine_t>

Definition at line 262 of file cpg_chrono_random.hpp.

◆ second_t

using cpg::chrono_random::second_t = typedef std::ratio<1>

Definition at line 57 of file cpg_chrono_random.hpp.

◆ seconds_t

Definition at line 67 of file cpg_chrono_random.hpp.

◆ time_point_t

using cpg::chrono_random::time_point_t = typedef std::chrono::time_point<high_resolution_clock_t>

Definition at line 72 of file cpg_chrono_random.hpp.

Function Documentation

◆ get_current_tick()

unsigned int cpg::chrono_random::get_current_tick ( )

Definition at line 79 of file cpg_chrono_random.hpp.

◆ random_fill() [1/10]

template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RType , template< typename, typename... > class RandomGeneratorType, typename... RTypes>
void cpg::chrono_random::random_fill ( ContainerType< Type, N > &  container,
const RandomGeneratorType< RType, RTypes... > &  random_generator 
)

Definition at line 405 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_fill() [2/10]

template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RandomGeneratorType >
void cpg::chrono_random::random_fill ( ContainerType< Type, N > &  container,
RandomGeneratorType &&  random_generator 
)

Definition at line 417 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_fill() [3/10]

template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RangeType >
void cpg::chrono_random::random_fill ( ContainerType< Type, N > &  container,
RangeType  range_start,
RangeType  range_end 
)

Definition at line 429 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_fill() [4/10]

template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RType , template< typename, typename... > class RandomGeneratorType, typename... RTypes>
void cpg::chrono_random::random_fill ( ContainerType< Type, Types... > &  container,
const RandomGeneratorType< RType, RTypes... > &  random_generator 
)

Definition at line 371 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_fill() [5/10]

template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename SizeType , template< typename, typename... > class RandomGeneratorType, typename... RTypes>
void cpg::chrono_random::random_fill ( ContainerType< Type, Types... > &  container,
const RandomGeneratorType< Type, RTypes... > &  random_generator,
SizeType  size 
)

Fills the /a container with random numbers. If the /a container is /a set or /a unordered_set, the range of the random_generator should be sufficiently big, otherwise it can fall into infinity loop.

Template Parameters
ContainerType
Type
Types
SizeType
RandomGeneratorType
RTypes
Parameters
container
random_generator
size

Definition at line 675 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_fill() [6/10]

template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RandomGeneratorType >
void cpg::chrono_random::random_fill ( ContainerType< Type, Types... > &  container,
RandomGeneratorType &&  random_generator 
)

Definition at line 383 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_fill() [7/10]

template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RangeType >
void cpg::chrono_random::random_fill ( ContainerType< Type, Types... > &  container,
RangeType  range_start,
RangeType  range_end 
)

Definition at line 395 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_fill() [8/10]

template<typename Type , std::size_t L, std::size_t M, std::size_t N, typename RandomGeneratorType >
void cpg::chrono_random::random_fill ( Type(&)  container[L][M][N],
RandomGeneratorType const &  random_generator 
)

Definition at line 360 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_fill() [9/10]

template<typename Type , std::size_t M, std::size_t N, typename RandomGeneratorType >
void cpg::chrono_random::random_fill ( Type(&)  container[M][N],
RandomGeneratorType const &  random_generator 
)

Definition at line 351 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_fill() [10/10]

template<typename Type , std::size_t N, typename RandomGeneratorType >
void cpg::chrono_random::random_fill ( Type(&)  container[N],
RandomGeneratorType const &  random_generator 
)

Definition at line 344 of file cpg_chrono_random.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ random_generator()

template<typename ValueType , typename RangeType1 , typename RangeType2 >
auto cpg::chrono_random::random_generator ( RangeType1  range_start,
RangeType2  range_end 
)

Definition at line 266 of file cpg_chrono_random.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ random_parallel_fill() [1/9]

template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RType , template< typename, typename... > class RandomGeneratorType, typename... RTypes>
void cpg::chrono_random::random_parallel_fill ( ContainerType< Type, N > &  container,
const RandomGeneratorType< RType, RTypes... > &  random_generator 
)

Definition at line 578 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_parallel_fill() [2/9]

template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RandomGeneratorType >
void cpg::chrono_random::random_parallel_fill ( ContainerType< Type, N > &  container,
RandomGeneratorType &&  random_generator 
)

Definition at line 613 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_parallel_fill() [3/9]

template<template< typename, std::size_t > class ContainerType, typename Type , std::size_t N, typename RangeType >
void cpg::chrono_random::random_parallel_fill ( ContainerType< Type, N > &  container,
RangeType  range_start,
RangeType  range_end 
)

Definition at line 648 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_parallel_fill() [4/9]

template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RType , template< typename, typename... > class RandomGeneratorType, typename... RTypes>
void cpg::chrono_random::random_parallel_fill ( ContainerType< Type, Types... > &  container,
const RandomGeneratorType< RType, RTypes... > &  random_generator 
)

Definition at line 496 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_parallel_fill() [5/9]

template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RandomGeneratorType >
void cpg::chrono_random::random_parallel_fill ( ContainerType< Type, Types... > &  container,
RandomGeneratorType &&  random_generator 
)

Definition at line 532 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_parallel_fill() [6/9]

template<template< typename, typename... > class ContainerType, typename Type , typename... Types, typename RangeType >
void cpg::chrono_random::random_parallel_fill ( ContainerType< Type, Types... > &  container,
RangeType  range_start,
RangeType  range_end 
)

Definition at line 567 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_parallel_fill() [7/9]

template<typename Type , std::size_t L, std::size_t M, std::size_t N, template< typename, typename... > class RandomGeneratorType, typename RType , typename... RTypes>
void cpg::chrono_random::random_parallel_fill ( Type(&)  container[L][M][N],
const RandomGeneratorType< RType, RTypes... > &  random_generator 
)

Definition at line 484 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_parallel_fill() [8/9]

template<typename Type , std::size_t M, std::size_t N, template< typename, typename... > class RandomGeneratorType, typename RType , typename... RTypes>
void cpg::chrono_random::random_parallel_fill ( Type(&)  container[M][N],
const RandomGeneratorType< RType, RTypes... > &  random_generator 
)

Definition at line 473 of file cpg_chrono_random.hpp.

Here is the call graph for this function:

◆ random_parallel_fill() [9/9]

template<typename Type , std::size_t N, template< typename, typename... > class RandomGeneratorType, typename RType , typename... RTypes>
void cpg::chrono_random::random_parallel_fill ( Type(&)  container[N],
const RandomGeneratorType< RType, RTypes... > &  random_generator 
)

Definition at line 439 of file cpg_chrono_random.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ random_words()

template<typename Type , size_t ArraySize>
cpg::chrono_random::random_words ( int  ,
int  ,
int  ,
const   Type(&)[ArraySize] 
) -> random_words< Type, ArraySize >

◆ seed()

unsigned int cpg::chrono_random::seed ( )
inline

Definition at line 75 of file cpg_chrono_random.hpp.

Here is the caller graph for this function:

◆ time_difference_in_unit()

template<typename TimeUnit >
double cpg::chrono_random::time_difference_in_unit ( const time_point_t start_time,
const time_point_t end_time 
)

Definition at line 92 of file cpg_chrono_random.hpp.

Variable Documentation

◆ now

auto& cpg::chrono_random::now = high_resolution_clock_t::now

Definition at line 73 of file cpg_chrono_random.hpp.