Boolean Vector. More...

#include <rboolvector.h>

Public Member Functions

 RBoolVector (size_t nb, bool val=false)
 
 RBoolVector (const RBoolVector &vec)
 
bool GetDefault (void) const
 
void SetDefault (bool val)
 
void ReSize (size_t size)
 
void Init (size_t nb, bool val)
 
bool IsSame (const RBoolVector &vector) const
 
void Set (bool value, size_t pos)
 
void Clear (void)
 
RBoolVectoroperator= (const RBoolVector &src)
 
bool operator[] (size_t i) const
 
bool & operator[] (size_t i)
 
const bool * GetList (void) const
 
size_t GetNb (void) const
 
size_t GetMax (void) const
 
virtual ~RBoolVector (void)
 

Private Member Functions

void Verify (size_t max)
 

Private Attributes

size_t NbBool
 
size_t MaxBool
 
bool * List
 
bool Default
 

Detailed Description

Boolean Vector.

The RBoolVector class provides a representation of a vector of boolean values. A default value (that can be modified) is assigned to new elements.

Constructor & Destructor Documentation

RBoolVector ( size_t  nb,
bool  val = false 
)

Construct the vector of boolean values.

Parameters
nbNumber of values.
valDefault value.
RBoolVector ( const RBoolVector vec)

Copy constructor.

Parameters
vecVector to copy.
virtual ~RBoolVector ( void  )
virtual

Destruct the vector.

Member Function Documentation

bool GetDefault ( void  ) const

Get the default value.

void SetDefault ( bool  val)

Set the default value that will be used for the new elements created in the future.

Parameters
valDefault value.
void Verify ( size_t  max)
private

Verify if the vector can hold a certain number of elements. If necessary, the vector is extended with undefined values.

Parameters
maxNumber of elements in the vector.
void ReSize ( size_t  size)

Resize the vector. If necessary, the vector is extended and new elements are set to the default value.

Parameters
sizeNumber of elements in the vector.
void Init ( size_t  nb,
bool  val 
)

Initialize the first element of the vector with a given values. If necessary, the vector is extended.

Parameters
nbNumber of elements.
valValue used to initialize.
bool IsSame ( const RBoolVector vector) const

Test if two vectors have exactly the same values.

Parameters
vectorVector used for the comparison.
Returns
True if the lists are the same.
void Set ( bool  value,
size_t  pos 
)

Set the boolean value at a given position. If necessary, the vector is extended and the new elements receive the default value.

Parameters
valueValue to insert.
posThe position where to insert.
void Clear ( void  )

Clear the vector (set all values to the default value).

RBoolVector& operator= ( const RBoolVector src)

Assignment operator.

Parameters
srcList used for the assignment.
bool operator[] ( size_t  i) const

Return the boolean value at position i. The first boolean value is at position 0 (const version).

Parameters
iIndex.
bool& operator[] ( size_t  i)

Return the boolean value at position i. The first boolean value is at position 0.

Parameters
iIndex.
const bool* GetList ( void  ) const

Get the list of the booleans contained in the vector.

size_t GetNb ( void  ) const

Get the number of values in the vector.

Returns
size_t
size_t GetMax ( void  ) const

Get the actual maximal number of values in the vector.

Returns
size_t

Field Documentation

size_t NbBool
private

Number of values in the vector.

size_t MaxBool
private

Maximal number of values in the vector.

bool* List
private

The array representing the boolean values.

bool Default
private

Default value.