GClasses
|
Useful functions for operating on vectors of indexes.
#include <GVec.h>
Public Member Functions | |
GIndexVec (size_t n=0) | |
~GIndexVec () | |
void | fillIndexes () |
Fills this vector with the values 0, 1, 2, ... More... | |
size_t & | operator[] (size_t index) |
Returns a reference to the specified element. More... | |
const size_t & | operator[] (size_t index) const |
Returns a const reference to the specified element. More... | |
size_t | popRandom (GRand &rand) |
Picks a random element from this vector, removes it, and returns it. More... | |
void | resize (size_t n) |
Resizes this vector. More... | |
size_t | size () const |
Returns the size of this vector. More... | |
Static Public Member Functions | |
static void | copy (size_t *pDest, const size_t *pSource, size_t nDims) |
This just wraps memcpy. More... | |
static void | deserialize (size_t *pVec, GDomListIterator &it) |
Load the vector from a text format. pVec must be large enough to contain all of the elements that remain in "it". More... | |
static size_t | indexOfMax (size_t *pVec, size_t size) |
Returns the index of the max value. In the event of a tie, the smallest index of one of the max values is returned. More... | |
static void | makeIndexVec (size_t *pVec, size_t size) |
Makes a vector of ints where each element contains its index (starting with zero, of course) More... | |
static size_t | maxValue (size_t *pVec, size_t size) |
Returns the max value. More... | |
static void | print (std::ostream &stream, size_t *pVec, size_t dims) |
Prints the values in the vector separated by ", ". More... | |
static GDomNode * | serialize (GDom *pDoc, const size_t *pVec, size_t dims) |
Write the vector to a text format. More... | |
static void | setAll (size_t *pVec, size_t value, size_t size) |
Sets all elements to the specified value. More... | |
static void | shuffle (size_t *pVec, size_t size, GRand *pRand) |
Shuffles the vector of ints. More... | |
Public Attributes | |
size_t * | m_data |
size_t | m_size |
GClasses::GIndexVec::GIndexVec | ( | size_t | n = 0 | ) |
GClasses::GIndexVec::~GIndexVec | ( | ) |
|
static |
This just wraps memcpy.
|
static |
Load the vector from a text format. pVec must be large enough to contain all of the elements that remain in "it".
void GClasses::GIndexVec::fillIndexes | ( | ) |
Fills this vector with the values 0, 1, 2, ...
|
static |
Returns the index of the max value. In the event of a tie, the smallest index of one of the max values is returned.
|
static |
Makes a vector of ints where each element contains its index (starting with zero, of course)
|
static |
Returns the max value.
|
inline |
Returns a reference to the specified element.
|
inline |
Returns a const reference to the specified element.
size_t GClasses::GIndexVec::popRandom | ( | GRand & | rand | ) |
Picks a random element from this vector, removes it, and returns it.
|
static |
Prints the values in the vector separated by ", ".
void GClasses::GIndexVec::resize | ( | size_t | n | ) |
Resizes this vector.
|
static |
Write the vector to a text format.
|
static |
Sets all elements to the specified value.
|
static |
Shuffles the vector of ints.
|
inline |
Returns the size of this vector.
size_t* GClasses::GIndexVec::m_data |
size_t GClasses::GIndexVec::m_size |