ZeroErr
Loading...
Searching...
No Matches
zeroerr::ElementOf< T > Class Template Reference

ElementOf is a domain that generates random values from a fixed set of elements. More...

#include <element_of.h>

Inheritance diagram for zeroerr::ElementOf< T >:
Collaboration diagram for zeroerr::ElementOf< T >:

Public Types

using ValueType = T
 
using CorpusType = uint64_t
 

Public Member Functions

 ElementOf (std::vector< T > elements)
 
CorpusType GetRandomCorpus (Rng &rng) override
 
ValueType GetValue (const CorpusType &v) const override
 
CorpusType FromValue (const ValueType &v) const override
 
void Mutate (Rng &rng, CorpusType &v, bool only_shrink) const override
 
- Public Member Functions inherited from zeroerr::Domain< T, uint64_t >
virtual ~Domain ()=default
 
virtual uint64_t GetRandomCorpus (Rng &rng) const=0
 
virtual T GetRandomValue (Rng &rng) const
 
virtual uint64_t ParseCorpus (IRObject v) const
 
virtual IRObject SerializeCorpus (const uint64_t &v) const
 

Public Attributes

std::vector< T > elements
 

Detailed Description

template<typename T>
class zeroerr::ElementOf< T >

ElementOf is a domain that generates random values from a fixed set of elements.

Template Parameters
TThe type of elements to generate

This domain allows generating random values by selecting from a predefined set of elements. The elements are provided as a vector during construction.

Example:

// Generate random values from a set of strings
auto domain = ElementOf<std::string>({"red", "green", "blue"});
// Generate random values from a set of integers
auto domain = ElementOf<int>({1, 2, 3, 4, 5});
ElementOf is a domain that generates random values from a fixed set of elements.
Definition element_of.h:28

Member Typedef Documentation

◆ CorpusType

template<typename T >
using zeroerr::ElementOf< T >::CorpusType = uint64_t

◆ ValueType

template<typename T >
using zeroerr::ElementOf< T >::ValueType = T

Constructor & Destructor Documentation

◆ ElementOf()

template<typename T >
zeroerr::ElementOf< T >::ElementOf ( std::vector< T >  elements)
inline

Member Function Documentation

◆ FromValue()

template<typename T >
CorpusType zeroerr::ElementOf< T >::FromValue ( const ValueType v) const
inlineoverridevirtual

◆ GetRandomCorpus()

template<typename T >
CorpusType zeroerr::ElementOf< T >::GetRandomCorpus ( Rng rng)
inlineoverride

◆ GetValue()

template<typename T >
ValueType zeroerr::ElementOf< T >::GetValue ( const CorpusType v) const
inlineoverridevirtual

◆ Mutate()

template<typename T >
void zeroerr::ElementOf< T >::Mutate ( Rng rng,
CorpusType v,
bool  only_shrink 
) const
inlineoverridevirtual

Member Data Documentation

◆ elements

template<typename T >
std::vector<T> zeroerr::ElementOf< T >::elements

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