ROSE  0.9.10.54
Classes | Typedefs | Functions
Rose::Combinatorics Namespace Reference

Description

Combinatoric functions.

Classes

class  Hasher
 Hash interface. More...
 
class  HasherFnv
 Fowler-Noll-Vo hashing using the Hasher interface. More...
 
class  HasherGcrypt
 Hasher for any libgcrypt hash algorithm. More...
 

Typedefs

typedef HasherGcrypt< 0 > HasherMd5
 
typedef HasherGcrypt< 0 > HasherSha1
 
typedef HasherGcrypt< 0 > HasherSha256
 
typedef HasherGcrypt< 0 > HasherSha384
 
typedef HasherGcrypt< 0 > HasherSha512
 
typedef HasherGcrypt< 0 > HasherCrc32
 

Functions

ROSE_DLL_API bool flip_coin ()
 Simulate flipping a coin. More...
 
template<typename T >
void shuffle (std::vector< T > &vector, size_t nitems=(size_t)(-1), size_t limit=(size_t)(-1), LinearCongruentialGenerator *lcg=NULL)
 Shuffle the values of a vector. More...
 
ROSE_DLL_API std::vector< uint8_t > sha1_digest (const uint8_t *data, size_t size) ROSE_DEPRECATED("use HasherSha1")
 
ROSE_DLL_API std::vector< uint8_t > sha1_digest (const std::vector< uint8_t > &data) ROSE_DEPRECATED("use HasherSha1")
 
ROSE_DLL_API std::vector< uint8_t > sha1_digest (const std::string &data) ROSE_DEPRECATED("use HasherSha1")
 
ROSE_DLL_API uint64_t fnv1a64_digest (const uint8_t *data, size_t size) ROSE_DEPRECATED("use HasherFnv")
 
ROSE_DLL_API uint64_t fnv1a64_digest (const std::vector< uint8_t > &data) ROSE_DEPRECATED("use HasherFnv")
 
ROSE_DLL_API uint64_t fnv1a64_digest (const std::string &data) ROSE_DEPRECATED("use HasherFnv")
 
ROSE_DLL_API std::string digest_to_string (const uint8_t *data, size_t size) ROSE_DEPRECATED("use Hasher")
 
ROSE_DLL_API std::string digest_to_string (const std::vector< uint8_t > &digest) ROSE_DEPRECATED("use Hasher")
 
ROSE_DLL_API std::string digest_to_string (const std::string &data) ROSE_DEPRECATED("use Hasher")
 
template<class T , class U >
std::vector< std::pair< T, U > > zip (const std::vector< T > &first, const std::vector< U > &second)
 Convert two vectors to a vector of pairs. More...
 
template<class T , class U >
std::pair< std::vector< T >, std::vector< U > > unzip (const std::vector< std::pair< T, U > > &pairs)
 Convert a vector of pairs to a pair of vectors. More...
 

Function Documentation

ROSE_DLL_API bool Rose::Combinatorics::flip_coin ( )

Simulate flipping a coin.

Randomly returns true or false with equal probability. See also, LinearCongruentialGenerator::flip_coin().

template<typename T >
void Rose::Combinatorics::shuffle ( std::vector< T > &  vector,
size_t  nitems = (size_t)(-1),
size_t  limit = (size_t)(-1),
LinearCongruentialGenerator lcg = NULL 
)

Shuffle the values of a vector.

If nitems is supplied then only the first nitems of the vector are shuffled. If limit is specified then the algorithm returns after at least the first limit elements are sufficiently shuffled. If an lcg is specified, then it will be used to generate the random numbers, otherwise a built-in random number generator is used.

Definition at line 72 of file Combinatorics.h.

template<class T , class U >
std::vector<std::pair<T, U> > Rose::Combinatorics::zip ( const std::vector< T > &  first,
const std::vector< U > &  second 
)

Convert two vectors to a vector of pairs.

If the two input vectors are not the same length, then the length of the result is the length of the shorter input vector.

Definition at line 315 of file Combinatorics.h.

template<class T , class U >
std::pair<std::vector<T>, std::vector<U> > Rose::Combinatorics::unzip ( const std::vector< std::pair< T, U > > &  pairs)

Convert a vector of pairs to a pair of vectors.

Definition at line 327 of file Combinatorics.h.