GClasses
GClasses::GIndexVec Class Reference

Detailed Description

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 GDomNodeserialize (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
 

Constructor & Destructor Documentation

GClasses::GIndexVec::GIndexVec ( size_t  n = 0)
GClasses::GIndexVec::~GIndexVec ( )

Member Function Documentation

static void GClasses::GIndexVec::copy ( size_t *  pDest,
const size_t *  pSource,
size_t  nDims 
)
static

This just wraps memcpy.

static void GClasses::GIndexVec::deserialize ( size_t *  pVec,
GDomListIterator it 
)
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 size_t GClasses::GIndexVec::indexOfMax ( size_t *  pVec,
size_t  size 
)
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 void GClasses::GIndexVec::makeIndexVec ( size_t *  pVec,
size_t  size 
)
static

Makes a vector of ints where each element contains its index (starting with zero, of course)

static size_t GClasses::GIndexVec::maxValue ( size_t *  pVec,
size_t  size 
)
static

Returns the max value.

size_t& GClasses::GIndexVec::operator[] ( size_t  index)
inline

Returns a reference to the specified element.

const size_t& GClasses::GIndexVec::operator[] ( size_t  index) const
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 void GClasses::GIndexVec::print ( std::ostream &  stream,
size_t *  pVec,
size_t  dims 
)
static

Prints the values in the vector separated by ", ".

void GClasses::GIndexVec::resize ( size_t  n)

Resizes this vector.

static GDomNode* GClasses::GIndexVec::serialize ( GDom pDoc,
const size_t *  pVec,
size_t  dims 
)
static

Write the vector to a text format.

static void GClasses::GIndexVec::setAll ( size_t *  pVec,
size_t  value,
size_t  size 
)
static

Sets all elements to the specified value.

static void GClasses::GIndexVec::shuffle ( size_t *  pVec,
size_t  size,
GRand pRand 
)
static

Shuffles the vector of ints.

size_t GClasses::GIndexVec::size ( ) const
inline

Returns the size of this vector.

Member Data Documentation

size_t* GClasses::GIndexVec::m_data
size_t GClasses::GIndexVec::m_size