Container of Numbers Cursor. More...

#include <rnumcursor.h>

Public Member Functions

 RNumCursor (void)
 
 RNumCursor (const RNumCursor &cur)
 
template<bool o>
 RNumCursor (const RNumContainer< I, o > &cont, size_t min=0, size_t max=SIZE_MAX)
 
template<bool o>
void Set (const RNumContainer< I, o > &cont, size_t min=0, size_t max=SIZE_MAX)
 
size_t GetNb (void) const
 
void Start (void)
 
void StartFromEnd (void)
 
bool End (void) const
 
bool Begin (void) const
 
void GoTo (size_t idx)
 
void Next (size_t inc=1)
 
void Prev (size_t inc=1)
 
operator() (void) const
 
I & operator() (void)
 
size_t GetPos (void) const
 

Private Attributes

size_t NbInt
 
I * List
 
I * Parse
 
size_t Pos
 
size_t First
 
size_t Last
 

Detailed Description

template<class I>
class R::RNumCursor< I >

Container of Numbers Cursor.

The RNumCursor class provides a cursor over a container of number.

Template Parameters
IType (int, double, etc.).
RNumContainer<double,false> a(3);
a[0]=1.0;
a[1]=2.0;
a[2]=3.0;
RNumCursor<double> Cur(a);
for(Cur.Start();!Cur.End();Cur.Next())
cout<<Cur()<<endl;

Constructor & Destructor Documentation

RNumCursor ( void  )

Construct a null cursor.

RNumCursor ( const RNumCursor< I > &  cur)

Copy constructor.

Parameters
curCursor to copy.
RNumCursor ( const RNumContainer< I, o > &  cont,
size_t  min = 0,
size_t  max = SIZE_MAX 
)

Construct a cursor over a given container.

Template Parameters
oDetermine if the container is ordered.
Parameters
contContainer of numbers.
minMinimum position of the elements to iterate.
maxMaximum position of the elements to iterate (included max). If SZE_MAX, iterate until the end of the container.

Member Function Documentation

void Set ( const RNumContainer< I, o > &  cont,
size_t  min = 0,
size_t  max = SIZE_MAX 
)

Set a cursor to a given container.

Template Parameters
oDetermine if the container is ordered.
Parameters
contContainer of numbers.
minMinimum position of the elements to iterate.
maxMaximum position of the elements to iterate (included max). If SZE_MAX, iterate until the end of the container.
size_t GetNb ( void  ) const

Get the number of values in the list.

Returns
size_t
void Start ( void  )

Start the iterator to go trough the list.

void StartFromEnd ( void  )

Start the iterator at the end of the container.

bool End ( void  ) const

Test if the end of the list is reached.

bool Begin ( void  ) const

Test if the begin of the list is reached.

void GoTo ( size_t  idx)

Go to the i-th position of the cursor.

Parameters
idxIndex of the element to get.
void Next ( size_t  inc = 1)

Go to a given number of next elements. If the end is reached, go to the beginning.

Parameters
incNumber of elements to go to.
void Prev ( size_t  inc = 1)

Go to a given number of previous elements. If the begin is reached, go to the end.

Parameters
incNumber of elements to go to.
I operator() ( void  ) const

Return the current element (const version).

I& operator() ( void  )

Return the current element.

size_t GetPos ( void  ) const

Return the actual position in the cursor.

Field Documentation

size_t NbInt
private

Number of values in the list.

I* List
private

The array representing the values.

I* Parse
private

Pointer used to parse the list.

size_t Pos
private

Current position parsed.

size_t First
private

The first position in the array handled by the cursor.

size_t Last
private

The last position in the array handled by the cursor.