Selector Class Reference

a random permutation of a random combination

`#include <Selector.h>`

## Public Member Functions

| Selector (UWORD32 m, std::string pp)
| Selector (UWORD32 m)
| Selector (const std::vector< UWORD32 > &retvals)
| ~Selector (void)
UWORD32 | operator[] (UWORD32 i)
UWORD32 | getRange (void) const

## Private Member Functions

void | calculate (UWORD32 m)
bool | idxX (UWORD32 v, UWORD32 m, UWORD32 *p) const
void | setX (UWORD32 i, UWORD32 v)

## Private Attributes

std::vector< UWORD32 > | X
std::vector< UWORD32 > | Y
sgi::hash_map< UWORD32, UWORD32 > | Xreversed
UWORD32 | Maximum
| operator[] will return a value in {0,...,Maximum-1}
UWORD32 | NumInArray
| the number of calculated positions in the arrays
PseudoRandomSource * | PRandom

## Constructor & Destructor Documentation

## Selector() [1/3]

Selector::Selector | ( | UWORD32 | m,
|  | std::string | pp )

construct a Selector object

Parameters

  m | the range - operator[] will return numbers in {0,...,m-1}
  pp | a passphrase used to generate the seed

## Selector() [2/3]

Selector::Selector | ( | UWORD32 | m | ) |

construct a Selector object that resembles the identity permutation with range m

Parameters

  m | the range - (*this)[i] will be i for i in {0,...,m-1}

## Selector() [3/3]

Selector::Selector | ( | const std::vector< UWORD32 > & | retvals | ) |

construct a Selector object that will return predefined values

Parameters

  retvals | the values that operator[] shall return

The Maximum is set to retvals.size().

## ~Selector()

Selector::~Selector | ( | void |  | ) |

## Member Function Documentation

## calculate()

void Selector::calculate | ( | UWORD32 | m | ) |

private

fill X, Y and Xreversed until but not including index m

## getRange()

UWORD32 Selector::getRange | ( | void |  | ) | const

inline

## idxX()

bool Selector::idxX | ( | UWORD32 | v,
|  | UWORD32 | m,
|  | UWORD32 * | p ) const

private

search an index i such that 0 <= i < m and X[i] == v

Parameters

  v | the value to be searched for in the X-array
  m | the upper bound for the index
  p | a pointer to a variable where the found index can be stored

Returns
  true iff such an index is found (*p is set to i in this case

## operator[]()

UWORD32 Selector::operator[] | ( | UWORD32 | i | ) |

get the value at the i-th position

Parameters

  i | an index

## setX()

void Selector::setX | ( | UWORD32 | i,
|  | UWORD32 | v )

private

set X[i] to v while maintaining Xreversed

## Member Data Documentation

## Maximum

UWORD32 Selector::Maximum

private

## NumInArray

UWORD32 Selector::NumInArray

private

## PRandom

PseudoRandomSource* Selector::PRandom

private

## X

std::vector<UWORD32> Selector::X

private

## Xreversed

sgi::hash_map<UWORD32,UWORD32> Selector::Xreversed

private

## Y

std::vector<UWORD32> Selector::Y

private

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

- Selector.h
- Selector.cc