Gadget
Public Member Functions | Protected Attributes | List of all members
IntVector Class Reference

This class implements a dynamic vector of int values. More...

#include <intvector.h>

Collaboration diagram for IntVector:
Collaboration graph

Public Member Functions

 IntVector ()
 This is the default IntVector constructor. More...
 
 IntVector (int sz, int initial)
 This is the IntVector constructor for a specified size with an initial value. More...
 
 IntVector (const IntVector &initial)
 This is the IntVector constructor that creates a copy of an existing IntVector. More...
 
 ~IntVector ()
 This is the IntVector destructor. More...
 
void resize (int addsize, int value)
 This will add new entries to the vector. More...
 
void Delete (int pos)
 This will delete an entry from the vector. More...
 
int Size () const
 This will return the size of the vector. More...
 
int & operator[] (int pos)
 This will return the value of an element of the vector. More...
 
const int & operator[] (int pos) const
 This will return the value of an element of the vector. More...
 
void Reset ()
 This will reset the vector. More...
 
void setToZero ()
 This function will set all of the entries of the vector to zero. More...
 
IntVectoroperator= (const IntVector &iv)
 This operator will set the vector equal to an existing IntVector. More...
 

Protected Attributes

int * v
 This is the vector of int values. More...
 
int size
 This is the size of the vector. More...
 

Detailed Description

This class implements a dynamic vector of int values.

Constructor & Destructor Documentation

◆ IntVector() [1/3]

IntVector::IntVector ( )
inline

This is the default IntVector constructor.

◆ IntVector() [2/3]

IntVector::IntVector ( int  sz,
int  initial 
)

This is the IntVector constructor for a specified size with an initial value.

Parameters
szis the size of the vector to be created
initialis the initial value for all the entries of the vector

◆ IntVector() [3/3]

IntVector::IntVector ( const IntVector initial)

This is the IntVector constructor that creates a copy of an existing IntVector.

Parameters
initialis the IntVector to copy

◆ ~IntVector()

IntVector::~IntVector ( )

This is the IntVector destructor.

Note
This will free all the memory allocated to all the elements of the vector

Member Function Documentation

◆ Delete()

void IntVector::Delete ( int  pos)

This will delete an entry from the vector.

Parameters
posis the element of the vector to be deleted
Note
This will free the memory allocated to the deleted element of the vector

◆ operator=()

IntVector & IntVector::operator= ( const IntVector iv)

This operator will set the vector equal to an existing IntVector.

Parameters
ivis the IntVector to copy

◆ operator[]() [1/2]

int& IntVector::operator[] ( int  pos)
inline

This will return the value of an element of the vector.

Parameters
posis the element of the vector to be returned
Returns
the value of the specified element

◆ operator[]() [2/2]

const int& IntVector::operator[] ( int  pos) const
inline

This will return the value of an element of the vector.

Parameters
posis the element of the vector to be returned
Returns
the value of the specified element

◆ Reset()

void IntVector::Reset ( )

This will reset the vector.

Note
This will delete every entry from the vector and set the size to zero

◆ resize()

void IntVector::resize ( int  addsize,
int  value 
)

This will add new entries to the vector.

Parameters
addsizeis the number of new entries to the vector
valueis the value that will be entered for the new entries

◆ setToZero()

void IntVector::setToZero ( )

This function will set all of the entries of the vector to zero.

◆ Size()

int IntVector::Size ( ) const
inline

This will return the size of the vector.

Returns
the size of the vector

Member Data Documentation

◆ size

int IntVector::size
protected

This is the size of the vector.

◆ v

int* IntVector::v
protected

This is the vector of int values.


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