DiaDes  0.1
DIAgnosis of Discrete-Event System
Classes | Typedefs | Enumerations | Functions
Diades::Utils Namespace Reference

Classes

class  AbstractNullValue
 
struct  AccumulateValidity
 
struct  AlwaysFalse
 
struct  AlwaysTrue
 
class  basic_substring
 
struct  BinaryAnd
 
struct  BinaryOr
 
struct  BinaryPredicate
 
class  Box
 A Box is a container that contains at most a reference to an object. More...
 
class  CBox
 A CBox is a container that contains at most a constant reference to an object. More...
 
class  CompositionFunctorFGx
 
class  CompositionFunctorFGxHx
 
class  CompositionFunctorFGxHy
 
class  Conjunction
 
class  ConstMapKeyIterator
 
class  ConstMapValueIterator
 
class  ConstRawPointerConstIterator
 
class  ConstUnorderedMapKeyIterator
 
class  ConstUnorderedMapValueIterator
 
class  Disjunction
 
class  Dispatcher
 
class  Exception
 
class  Failure
 
class  FileReporting
 
class  FunctionException
 
class  GenericLabel
 
class  GFS
 
class  Identifier
 An Identifier is a reference to a string (IdentifierData) that only contains alpha-numeric characters and underscores. More...
 
class  IdentifierData
 This is the internal representation of an Identifier. More...
 
class  IdentifierFactory
 A IdentifierFactory is a factory in charge of creating IdentifierData. More...
 
class  IdGenerator
 
class  IncrementGenerator
 
class  InfoManager
 
class  Interval
 
class  IntervalInvalid
 
struct  Is
 
struct  IsIn
 
struct  IsNotIn
 
class  LabelGenerator
 
class  Log
 
class  Loggable
 
class  Logger
 
class  LoggerData
 
class  LoggerFactory
 
class  MapKeyIterator
 
class  MapValueIterator
 
class  NAryTree
 
class  NoDelimiter
 
class  NullValue
 
class  NullValue< size_t >
 
class  NullValue< std::string >
 
class  NullValue< unsigned >
 
class  PartialOrder
 
class  PrefixedCounterIdGenerator
 
class  Ptr
 
class  QuotedLabel
 
class  Range
 
class  RangeMapperIterator
 
class  RangesEnumeration
 
class  RawPointerIterator
 
class  Selection
 
class  SharedPointerConstIterator
 
class  SharedPointerIterator
 
class  StringBinaryCombination
 
class  StringDelimiter
 
struct  StringHash
 
class  Timer
 
class  TimerFactory
 
class  TimerInvalid
 
class  TimerTimeOut
 
class  ToStream
 
struct  UnaryAnd
 
struct  UnaryOr
 
struct  UnaryPredicate
 
class  UnorderedMapKeyIterator
 
class  UnorderedMapValueIterator
 
class  UnquotedLabel
 
struct  Validity
 
class  Verbose
 

Typedefs

typedef UnquotedLabel< char, std::char_traits< char >, std::allocator< char > > UnquotedStringLabel
 
typedef UnquotedLabel< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > UnquotedWideStringLabel
 
typedef QuotedLabel< char, std::char_traits< char >, std::allocator< char > > QuotedStringLabel
 
typedef QuotedLabel< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > QuotedWideStringLabel
 
typedef LabelGenerator< char, std::char_traits< char >, std::allocator< char > > UnquotedStringLabelGenerator
 
typedef LabelGenerator< wchar_t, std::char_traits< wchar_t >, std::allocator< wchar_t > > UnquotedWideStringLabelGenerator
 
template<typename Key , typename Value >
using Map = std::map< Key, Value >
 
template<typename Key , typename Value >
using MapIterator = typename Map< Key, Value >::iterator
 
template<typename Key , typename Value >
using ConstMapIterator = typename Map< Key, Value >::const_iterator
 
template<typename Key , typename Value >
using UnorderedMap = std::unordered_map< Key, Value >
 
template<typename Key , typename Value >
using UnorderedMapIterator = typename UnorderedMap< Key, Value >::iterator
 
template<typename Key , typename Value >
using ConstUnorderedMapIterator = typename UnorderedMap< Key, Value >::const_iterator
 
typedef basic_substring< char > Substring
 
typedef boost::format Msg
 

Enumerations

enum  LogLevel {
  LgNothing =0, LgOutput =1, LgProcess =2, LgCritical =3,
  LgError =4, LgWarning =5, LgInfo =6, LgDebug =7
}
 
enum  VerboseLevel {
  VbNothing, VbOutput, VbProcess, VbCritical,
  VbError, VbWarning, VbInfo, VbDebug
}
 

Functions

template<typename InputIterator >
IsIn< InputIterator > isIn (InputIterator first, InputIterator last)
 
template<typename InputIterator >
IsNotIn< InputIterator > isNotIn (InputIterator first, InputIterator last)
 
template<typename InputIterator , typename OutputIterator1 , typename OutputIterator2 , typename _UnaryPredicate >
void dispatch (InputIterator first, InputIterator last, OutputIterator1 output1, OutputIterator2 output2, _UnaryPredicate predicate)
 
template<class F , class G , class H >
CompositionFunctorFGxHx< F, G, H > fgxhx (const F &f, const G &g, const H &h)
 
template<class F , class G >
CompositionFunctorFGx< F, G > fgx (const F &f, const G &g)
 
template<class F , class G , class H >
CompositionFunctorFGxHy< F, G, H > fgxhy (const F &f, const G &g, const H &h)
 
template<class Predicate1 , class Predicate2 >
UnaryAnd< Predicate1, Predicate2 > unaryAnd (const Predicate1 &p1, const Predicate2 &p2)
 
template<class Predicate1 , class Predicate2 >
UnaryOr< Predicate1, Predicate2 > unaryOr (const Predicate1 &p1, const Predicate2 &p2)
 
template<class Predicate1 , class Predicate2 >
BinaryAnd< Predicate1, Predicate2 > binaryAnd (const Predicate1 &p1, const Predicate2 &p2)
 
template<class Predicate1 , class Predicate2 >
BinaryOr< Predicate1, Predicate2 > binaryOr (const Predicate1 &p1, const Predicate2 &p2)
 
istream & getIdentifierString (istream &is, std::string &identifier)
 
std::ostream & operator<< (std::ostream &os, const Identifier &identifier)
 
template<typename CharT , typename Traits , typename Alloc >
bool readLabel (std::basic_istream< CharT > &stream, std::basic_string< CharT, Traits, Alloc > &label)
 
template<LogLevel level>
Log log (Logger logger, const string &msg)
 
template<LogLevel level>
Log log (const string &msg)
 
template<LogLevel level>
void saveLog (Logger logger, ostream &os)
 
template<LogLevel level>
void saveLog (ostream &os)
 
void saveAllLogs (ostream &os)
 
template<typename InputIterator1 , typename InputIterator2 >
int sequenceHamming (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
 
template<typename InputIterator1 , typename InputIterator2 >
int orderedHamming (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
 
template<typename InputIterator1 , typename InputIterator2 >
int intersectionSize (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
 
template<typename InputIterator1 , typename InputIterator2 >
int differenceSize (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
 
double generateRandomDouble (double lower, double upper)
 
long generateRandomValue (long lower, long upper)
 
unsigned initialiseSeed ()
 
void initialiseRandomGenerator (unsigned int seed)
 
void selectNValues (unsigned int min, unsigned int max, unsigned int n, set< unsigned > &result)
 
template<typename Iterator >
Iterator selectRandomElement (unsigned number, Iterator first, Iterator last)
 
template<typename Iterator , typename Predicate >
Iterator selectRandomElement (Iterator first, Iterator last, Predicate pred)
 
template<typename InputIterator , typename Predicate , typename OutputIterator >
void selectNRandomElements (InputIterator first, InputIterator last, Predicate pred, unsigned number, OutputIterator out)
 
template<typename CharT >
bool readChars (std::basic_istream< CharT > &is, const std::unordered_set< CharT > &characters, CharT &next)
 
template<class CharType , class CharTraits , class InputIterator >
InputIterator getFileExtension (const std::basic_string< CharType, CharTraits > &fileName, InputIterator begin, InputIterator end)
 
template<class CharType , class CharTraits >
bool hasOnlyWhiteSpaces (const std::basic_string< CharType, CharTraits > &sequence, typename std::basic_string< CharType, CharTraits >::size_type &index)
 
template<typename T >
std::vector< T >::size_type swapRemove (std::vector< T > &myVector, typename std::vector< T >::size_type index)
 
template<typename T >
std::vector< T >::size_type swapRemove (std::vector< T > &myVector, typename std::vector< T >::iterator &it)
 
template<typename T >
std::vector< T >::size_type swapRemoveFirst (std::vector< T > &myVector, const T &element)
 
template<typename T >
std::vector< T >::size_type swapRemove (std::vector< T > &myVector, const T &element)
 

Typedef Documentation

◆ ConstMapIterator

template<typename Key , typename Value >
using Diades::Utils::ConstMapIterator = typedef typename Map<Key, Value>::const_iterator

Definition at line 124 of file MapIterators.hh.

◆ ConstUnorderedMapIterator

template<typename Key , typename Value >
using Diades::Utils::ConstUnorderedMapIterator = typedef typename UnorderedMap<Key, Value>::const_iterator

Definition at line 315 of file MapIterators.hh.

◆ Map

template<typename Key , typename Value >
using Diades::Utils::Map = typedef std::map<Key, Value>

Definition at line 29 of file MapIterators.hh.

◆ MapIterator

template<typename Key , typename Value >
using Diades::Utils::MapIterator = typedef typename Map<Key, Value>::iterator

Definition at line 32 of file MapIterators.hh.

◆ Msg

typedef boost::format Diades::Utils::Msg

Msg shortest way to write boost::format (recommended to use in Diades)

Definition at line 42 of file Verbose.hh.

◆ QuotedStringLabel

typedef QuotedLabel<char, std::char_traits<char>, std::allocator<char> > Diades::Utils::QuotedStringLabel

Definition at line 332 of file Label.hh.

◆ QuotedWideStringLabel

typedef QuotedLabel<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > Diades::Utils::QuotedWideStringLabel

Definition at line 333 of file Label.hh.

◆ Substring

Definition at line 50 of file Substring.hh.

◆ UnorderedMap

template<typename Key , typename Value >
using Diades::Utils::UnorderedMap = typedef std::unordered_map<Key, Value>

Definition at line 220 of file MapIterators.hh.

◆ UnorderedMapIterator

template<typename Key , typename Value >
using Diades::Utils::UnorderedMapIterator = typedef typename UnorderedMap<Key, Value>::iterator

Definition at line 223 of file MapIterators.hh.

◆ UnquotedStringLabel

typedef UnquotedLabel<char, std::char_traits<char>, std::allocator<char> > Diades::Utils::UnquotedStringLabel

Definition at line 330 of file Label.hh.

◆ UnquotedStringLabelGenerator

typedef LabelGenerator<char, std::char_traits<char>, std::allocator<char> > Diades::Utils::UnquotedStringLabelGenerator

Definition at line 462 of file Label.hh.

◆ UnquotedWideStringLabel

typedef UnquotedLabel<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > Diades::Utils::UnquotedWideStringLabel

Definition at line 331 of file Label.hh.

◆ UnquotedWideStringLabelGenerator

typedef LabelGenerator<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > Diades::Utils::UnquotedWideStringLabelGenerator

Definition at line 463 of file Label.hh.

Enumeration Type Documentation

◆ LogLevel

LgOutput: normal output of the process LgProcess: output about the behaviour of the process LgCritical: critical output about the behaviour of the process LgError: detected error in the process LgWarning: for the warning LgInfo: other type of information LgDebug: information for debug only

Enumerator
LgNothing 
LgOutput 
LgProcess 
LgCritical 
LgError 
LgWarning 
LgInfo 
LgDebug 

Definition at line 49 of file Logger.hh.

◆ VerboseLevel

Enumerator
VbNothing 
VbOutput 
VbProcess 
VbCritical 
VbError 
VbWarning 
VbInfo 
VbDebug 

Definition at line 19 of file Verbose.hh.

Function Documentation

◆ binaryAnd()

template<class Predicate1 , class Predicate2 >
BinaryAnd<Predicate1, Predicate2> Diades::Utils::binaryAnd ( const Predicate1 &  p1,
const Predicate2 &  p2 
)
inline
Parameters
p1a boolean unary predicate
p2a boolean unary predicate
Returns
the boolean binary predicate p1 and p2 (use CompositionFunctorFGxHy)

Definition at line 540 of file Functors.hh.

◆ binaryOr()

template<class Predicate1 , class Predicate2 >
BinaryOr<Predicate1, Predicate2> Diades::Utils::binaryOr ( const Predicate1 &  p1,
const Predicate2 &  p2 
)
inline
Parameters
p1a boolean unary predicate
p2a boolean unary predicate
Returns
the boolean binary predicate p1 or p2 (use CompositionFunctorFGxHy)

Definition at line 554 of file Functors.hh.

◆ differenceSize()

template<typename InputIterator1 , typename InputIterator2 >
int Diades::Utils::differenceSize ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
InputIterator2  last2 
)

Compute the number of elements that are in the first ordered range but not in the other one. If the same element occurs twice it will be considered as two elements. The elements must be comparable

Parameters
first1iterator on the first element of range 1
last1iterator on the element after the last one in range 1
first2iterator on the first element of range 2
last2iterator on the element after the last one in range 2
Returns
the hamming distance between the sets defined in [first1,last1( and [first2.last2(

Definition at line 171 of file Measures.hh.

Referenced by Diades::Automata::NonCommonFaults::operator()().

◆ dispatch()

template<typename InputIterator , typename OutputIterator1 , typename OutputIterator2 , typename _UnaryPredicate >
void Diades::Utils::dispatch ( InputIterator  first,
InputIterator  last,
OutputIterator1  output1,
OutputIterator2  output2,
_UnaryPredicate  predicate 
)

Template function for dispatching a range of objects depending on the result of a unary boolean Predicte

Parameters
firstfirst iterator of the range to dispatch
lastlast iterator of the range to dispatch
output1output iterator to insert object such that the Predicate is true
output2output iterator to insert object such that the Predicate is false
predicatethe boolean unary predicate

Definition at line 245 of file Functors.hh.

◆ fgx()

template<class F , class G >
CompositionFunctorFGx<F, G> Diades::Utils::fgx ( const F &  f,
const G &  g 
)
inline
Parameters
fbinary functor
gunary functor
Returns
the corresponding CompositionFunctorFGx functor

function for convenience

Definition at line 373 of file Functors.hh.

Referenced by Diades::Automata::randomSimulateState().

◆ fgxhx()

template<class F , class G , class H >
CompositionFunctorFGxHx<F, G, H> Diades::Utils::fgxhx ( const F &  f,
const G &  g,
const H &  h 
)
inline
Parameters
fbinary functor
gunary functor
hunary functor
Returns
the corresponding CompositionFunctorFGxHx functor

function for convenience

Definition at line 319 of file Functors.hh.

◆ fgxhy()

template<class F , class G , class H >
CompositionFunctorFGxHy<F, G, H> Diades::Utils::fgxhy ( const F &  f,
const G &  g,
const H &  h 
)
inline
Parameters
fbinary functor
gunary functor
hunary functor
Returns
the corresponding CompositionFunctorFGxHx functor

function for convenience

Definition at line 429 of file Functors.hh.

◆ generateRandomDouble()

double Diades::Utils::generateRandomDouble ( double  lower,
double  upper 
)

Generation of a random double in [lower,upper]

◆ generateRandomValue()

long Diades::Utils::generateRandomValue ( long  lower,
long  upper 
)

◆ getFileExtension()

template<class CharType , class CharTraits , class InputIterator >
InputIterator Diades::Utils::getFileExtension ( const std::basic_string< CharType, CharTraits > &  fileName,
InputIterator  begin,
InputIterator  end 
)

Get the extension (suffix) of a filename

Parameters
fileNamename of a file
beginiterator on the first possible extension
enditerator on the element after the last possible extension
Returns
an iterator on the extension of the file name if it belongs to the range [begin,end(, return end otherwise

Definition at line 57 of file StringTools.hh.

Referenced by Diades::CmdInterface::fileSuffixOk(), getInterface(), Diades::CmdInterface::getParameterList(), main(), and readParameters().

◆ getIdentifierString()

istream& Diades::Utils::getIdentifierString ( istream &  is,
std::string &  identifier 
)
Parameters
isinput stream
identifierthe resulting string
Returns
the input stream after reading the identifier. 'identifier' contains the identifier contained in the input stream An identifier is a non-empty ascii-based string that starts with either a letter or the character '_' followed by letters digits and '_'

◆ hasOnlyWhiteSpaces()

template<class CharType , class CharTraits >
bool Diades::Utils::hasOnlyWhiteSpaces ( const std::basic_string< CharType, CharTraits > &  sequence,
typename std::basic_string< CharType, CharTraits >::size_type &  index 
)

Check whether the given sequence only contains whitespaces (or tabs)

Parameters
sequencethe sequence to analyse
indexthe returning index of the first character that is not a whitespace in the sequence or npos if such a character does not exist
Returns
true iff sequence only contains whitespaces

Definition at line 92 of file StringTools.hh.

◆ initialiseRandomGenerator()

void Diades::Utils::initialiseRandomGenerator ( unsigned int  seed)

Initialise the random generator with a seed

Referenced by main().

◆ initialiseSeed()

unsigned Diades::Utils::initialiseSeed ( )

Initialise a seed for the random generator, note that the random generator must be initialised with the seed with initialiseRandomGenerator

Referenced by main().

◆ intersectionSize()

template<typename InputIterator1 , typename InputIterator2 >
int Diades::Utils::intersectionSize ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
InputIterator2  last2 
)

Compute the number of common elements in the two ordered ranges. If the same element occurs twice it will be considered as two elements. The elements must be comparable

Parameters
first1iterator on the first element of range 1
last1iterator on the element after the last one in range 1
first2iterator on the first element of range 2
last2iterator on the element after the last one in range 2
Returns
the hamming distance between the sets defined in [first1,last1( and [first2.last2(

Definition at line 126 of file Measures.hh.

Referenced by Diades::Automata::CommonFaults::operator()(), Diades::Automata::Accuracy::operator()(), Diades::Automata::BsAccuracy::operator()(), and Diades::Automata::FcAccuracy::operator()().

◆ isIn()

template<typename InputIterator >
IsIn<InputIterator> Diades::Utils::isIn ( InputIterator  first,
InputIterator  last 
)
inline
Parameters
firstfirst iterator of the range to search in
lastlast iterator of the range to search in
Returns
an IsIn functor initialised with [first,last[

Definition at line 141 of file Functors.hh.

Referenced by Diades::Automata::Experimental::ComposableModel< Fsm, StateCreator >::checkSynchronisationEvent().

◆ isNotIn()

template<typename InputIterator >
IsNotIn<InputIterator> Diades::Utils::isNotIn ( InputIterator  first,
InputIterator  last 
)
inline
Parameters
firstfirst iterator of the range to search in
lastlast iterator of the range to search in
Returns
an IsNotIn functor initialised with [first,last[

Definition at line 226 of file Functors.hh.

Referenced by Diades::Automata::randomSimulateState(), and writeFinalPartOfSimulation().

◆ log() [1/2]

template<LogLevel level>
Log Diades::Utils::log ( Logger  logger,
const string &  msg 
)

◆ log() [2/2]

template<LogLevel level>
Log Diades::Utils::log ( const string &  msg)

Log a message with a given level to the default logger

Parameters
loggerthe Logger
msgthe message
Returns
the Log

Definition at line 143 of file Log.hh.

References Diades::Utils::Log::Log().

◆ operator<<()

std::ostream& Diades::Utils::operator<< ( std::ostream &  os,
const Identifier identifier 
)
inline

◆ orderedHamming()

template<typename InputIterator1 , typename InputIterator2 >
int Diades::Utils::orderedHamming ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
InputIterator2  last2 
)

Compute the hamming distance between two ordered ranges. If the same element occurs twice it will be considered as two elements. The elements must be comparable

Parameters
first1iterator on the first element of range 1
last1iterator on the element after the last one in range 1
first2iterator on the first element of range 2
last2iterator on the element after the last one in range 2
Returns
the hamming distance between the sets defined in [first1,last1( and [first2.last2(

Definition at line 71 of file Measures.hh.

Referenced by Diades::Automata::Distance::operator()(), Diades::Automata::FcDistance::operator()(), and Diades::Automata::BsDistance::operator()().

◆ readChars()

template<typename CharT >
bool Diades::Utils::readChars ( std::basic_istream< CharT > &  is,
const std::unordered_set< CharT > &  characters,
CharT &  next 
)
Parameters
isan input stream
charactersa set of characters
nextthe next character in the stream that is not part of 'characters'
Returns
true if the character next exists. false otherwise.

Definition at line 27 of file StreamTools.hh.

Referenced by Diades::Automata::Experimental::AutFileDescriptor< DdAutEventId >::autFileHeader().

◆ readLabel()

template<typename CharT , typename Traits , typename Alloc >
bool Diades::Utils::readLabel ( std::basic_istream< CharT > &  stream,
std::basic_string< CharT, Traits, Alloc > &  label 
)

Read a label from a stream

Parameters
streamthe stream that contain the event
labelthe returned label
Returns
true if the read is a success

Definition at line 279 of file Label.hh.

References Diades::Utils::GenericLabel< CharT, Traits, Alloc >::isNull(), Diades::Utils::QuotedLabel< CharT, Traits, Alloc >::nudeString(), and Diades::Utils::GenericLabel< CharT, Traits, Alloc >::toString().

Referenced by Diades::Automata::Experimental::ReadEvent< std::string >::operator()().

◆ saveAllLogs()

void Diades::Utils::saveAllLogs ( ostream &  os)

Output the available logs

Parameters
osoutput stream
Returns
the Log

Referenced by main(), and saveLog().

◆ saveLog() [1/2]

template<LogLevel level>
void Diades::Utils::saveLog ( Logger  logger,
ostream &  os 
)

Output the logs

Parameters
loggerthe Logger
osoutput stream
Returns
the Log

Definition at line 163 of file Log.hh.

References Diades::Utils::Logger::printLevel().

Referenced by main(), readModels(), saveLog(), startInteractiveSimulation(), and startNonInteractiveSimulation().

◆ saveLog() [2/2]

template<LogLevel level>
void Diades::Utils::saveLog ( ostream &  os)

Output the logs

Parameters
loggerthe Logger
osoutput stream
Returns
the Log

Output the default logs

Parameters
osoutput stream
Returns
the Log

Definition at line 180 of file Log.hh.

References Diades::Utils::Logger::printLevel(), saveAllLogs(), and saveLog().

◆ selectNRandomElements()

template<typename InputIterator , typename Predicate , typename OutputIterator >
void Diades::Utils::selectNRandomElements ( InputIterator  first,
InputIterator  last,
Predicate  pred,
unsigned  number,
OutputIterator  out 
)
Parameters
firstAn iterator on the first element
lastAn iterator on the element after the last one
predA predicate
numberThe number of elements to select
outa set of n selected elements from [first,last( such that pred(Element) is added, no element is added otherwise

Definition at line 145 of file Random.hh.

References selectNValues().

◆ selectNValues()

void Diades::Utils::selectNValues ( unsigned int  min,
unsigned int  max,
unsigned int  n,
set< unsigned > &  result 
)

Select randomly n values in the range [min,max]

Parameters
minthe minimum of the range
maxthe maximum of the range
nthe number of selected values
resultthe selected values empty result if the parameters are not compatible.

Referenced by generateFaults(), main(), and selectNRandomElements().

◆ selectRandomElement() [1/2]

template<typename Iterator >
Iterator Diades::Utils::selectRandomElement ( unsigned  number,
Iterator  first,
Iterator  last 
)
Parameters
numberThe number of elements in [first,last(
firstAn iterator on the first element
lastAn iterator on the element after the last one
Returns
an Element from [first,last( if success, maybe Element() if number not properly set
Precondition
number > 0 && <= [first,last(.size()

Definition at line 68 of file Random.hh.

References generateRandomValue().

Referenced by Diades::Automata::randomSimulate(), and Diades::Automata::randomSimulateState().

◆ selectRandomElement() [2/2]

template<typename Iterator , typename Predicate >
Iterator Diades::Utils::selectRandomElement ( Iterator  first,
Iterator  last,
Predicate  pred 
)
Parameters
firstAn iterator on the first element
lastAn iterator on the element after the last one
predA prdicate
Returns
an Element from [first,last( if success such that pred(Element), otherwise it returns last
If the number of elements in [first,last( is known, it is better to use
the selectRandomElement function with the number as a parameter.

Definition at line 107 of file Random.hh.

References generateRandomValue().

◆ sequenceHamming()

template<typename InputIterator1 , typename InputIterator2 >
int Diades::Utils::sequenceHamming ( InputIterator1  first1,
InputIterator1  last1,
InputIterator2  first2,
InputIterator2  last2 
)

Compute the hamming distance between two sequences

Parameters
first1iterator on the first element of range 1
last1iterator on the element after the last one in range 1
first2iterator on the first element of range 2
last2iterator on the element after the last one in range 2
Returns
the hamming distance between [first1,last1( and [first2.last2(, -1 if not success (not the same range size)
Todo:
test

Definition at line 34 of file Measures.hh.

◆ swapRemove() [1/3]

template<typename T >
std::vector<T>::size_type Diades::Utils::swapRemove ( std::vector< T > &  myVector,
typename std::vector< T >::size_type  index 
)

Remove the element from myVector

Parameters
myVector
index
Returns
the index of the element that has been swapped or myVector.size() if no swap happened when the element is removed. The purpose of this function is to remove the element at index of the vector by swapping the element with the last one to avoid the linear complexity of the event shifting/copying of myVector.erase(element). Obsviously the order in myVector is changed if a swap has occurred between the last element of the vector and the element to remove.
Postcondition
if index is a proper index of the vector, then the vector size is reduced after removal.

Definition at line 35 of file VectorTools.hh.

Referenced by Diades::Automata::Experimental::StateMachine< _StatePropertyId, _InputSymbolId, _NullStatePropertyId, _NullInputSymbolId >::eraseEventPropertyId(), swapRemove(), and swapRemoveFirst().

◆ swapRemove() [2/3]

template<typename T >
std::vector<T>::size_type Diades::Utils::swapRemove ( std::vector< T > &  myVector,
typename std::vector< T >::iterator &  it 
)

Remove the occurrence of element from myVector

Parameters
myVector
elementan iterator
Returns
the index of the element that has been swapped or myVector.size() if no swap happened when the element is removed. The purpose of this function is to remove the element referenced by the iterator in the vector by swapping the element with the last one to avoid the linear complexity of the event shifting/copying of myVector.erase(element). Obsviously the order in myVector is changed if a swap has occurred between the last element of the vector and the element to remove.
Precondition
no check whether the iterator is valid, ensure that the iterator is a reference to a proper element of myVector
Postcondition
if element is a proper element of the vector, then the vector size is reduced after removal.

Definition at line 74 of file VectorTools.hh.

References swapRemove().

◆ swapRemove() [3/3]

template<typename T >
std::vector<T>::size_type Diades::Utils::swapRemove ( std::vector< T > &  myVector,
const T &  element 
)

Remove all the occurrences of element from myVector

Parameters
myVector
element
Returns
the last index of the element that has been swapped or myVector.size() if no swap happened when the element is removed. The purpose of this function is to remove any occurrence of an element in the vector by swapping the element with the last one to avoid the linear complexity of the event shifting/copying of myVector.erase(element). Obsviously the order in myVector is changed if a swap has occurred between the last element of the vector and the element to remove.
Postcondition
if element is contained n times in the vector, then the vector size is reduced of n.

Definition at line 122 of file VectorTools.hh.

References swapRemove().

◆ swapRemoveFirst()

template<typename T >
std::vector<T>::size_type Diades::Utils::swapRemoveFirst ( std::vector< T > &  myVector,
const T &  element 
)

Remove the first occurrence of element from myVector

Parameters
myVector
element
Returns
the index of the element that has been swapped or myVector.size() if no swap happened when the element is removed. The purpose of this function is to remove the first occurrence of an element in the vector by swapping the element with the last one to avoid the linear complexity of the event shifting/copying of myVector.erase(element). Obsviously the order in myVector is changed if a swap has occurred between the last element of the vector and the element to remove.
Postcondition
if element is a proper element of the vector, then the vector size is reduced after removal.

Definition at line 96 of file VectorTools.hh.

References swapRemove().

◆ unaryAnd()

template<class Predicate1 , class Predicate2 >
UnaryAnd<Predicate1, Predicate2> Diades::Utils::unaryAnd ( const Predicate1 &  p1,
const Predicate2 &  p2 
)
inline
Parameters
p1a boolean unary predicate
p2a boolean unary predicate
Returns
the boolean unary predicate p1 and p2 (use CompositionFunctorFGxHx)

Definition at line 477 of file Functors.hh.

Referenced by writeFinalPartOfSimulation().

◆ unaryOr()

template<class Predicate1 , class Predicate2 >
UnaryOr<Predicate1, Predicate2> Diades::Utils::unaryOr ( const Predicate1 &  p1,
const Predicate2 &  p2 
)
inline
Parameters
p1a boolean unary predicate
p2a boolean unary predicate
Returns
the boolean unary predicate p1 or p2 (use CompositionFunctorFGxHx)

Definition at line 491 of file Functors.hh.