Container Cursor. More...
#include <rcursor.h>
Public Member Functions | |
RCursor (void) | |
RCursor (const RCursor< C > &src) | |
RCursor (const iRContainer< C > &c, size_t min=0, size_t max=SIZE_MAX) | |
RCursor< C > & | operator= (const RCursor< C > &src) |
void | Set (const iRContainer< C > &c, size_t min=0, size_t max=SIZE_MAX) |
void | Clear (void) |
void | Start (void) |
void | StartFromEnd (void) |
void | GoTo (size_t idx) |
template<bool a, bool o> | |
void | DeleteCurrent (RContainer< C, a, o > &c) |
size_t | GetPos (void) const |
size_t | GetMaxPos (void) const |
size_t | GetNb (void) const |
bool | Begin (void) const |
bool | End (void) const |
bool | IsAt (size_t idx) const |
void | Next (size_t inc=1) |
void | Prev (size_t inc=1) |
C * | operator() (void) const |
Protected Attributes | |
C ** | Current |
size_t | ActPtr |
C ** | Tab |
size_t | NbPtr |
size_t | CurNbPtr |
size_t | FirstPtr |
size_t | LastPtr |
Detailed Description
template<class C>
class R::RCursor< C >
Container Cursor.
This class represent a cursor iterating a RContainer.
- Parameters
-
C Class of the elements of the container.
Contrary to R::RCastCursor<C>, the elements iterated can be modified.
Here is an example of a cursor used:
- Attention
- When an element is added or removed from the container parsed by the cursor, the cursor is not valid anymore.
Constructor & Destructor Documentation
RCursor | ( | void | ) |
Construct the cursor.
RCursor | ( | const iRContainer< C > & | c, |
size_t | min = 0 , |
||
size_t | max = SIZE_MAX |
||
) |
Construct the cursor.
- Parameters
-
c Container to iterate. min Minimum position of the elements to iterate. max Maximum position of the elements to iterate (included max). If SIZE_MAX, iterate until the end of the container.
Member Function Documentation
Assignment operator using a "Cursor".
- Parameters
-
src Source container.
void Set | ( | const iRContainer< C > & | c, |
size_t | min = 0 , |
||
size_t | max = SIZE_MAX |
||
) |
Set the container.
- Parameters
-
c Container to iterate. min Minimum position of the elements to iterate. max Maximum position of the elements to iterate (included max). If SIZE_MAX, iterate until the end of the container.
void Clear | ( | void | ) |
Clear the cursor.
void Start | ( | void | ) |
Start the iterator at the beginning of the container.
void StartFromEnd | ( | void | ) |
Start the iterator at the end of the container.
void GoTo | ( | size_t | idx | ) |
Go to the i-th position of the cursor, event if this position contains a null pointer.
- Parameters
-
idx Index of the element to get.
void DeleteCurrent | ( | RContainer< C, a, o > & | c | ) |
Delete the current element from the container.
- Parameters
-
c Container to delete from. Must be the one associated with the cursor.
size_t GetPos | ( | void | ) | const |
Get the actual position in the cursor.
size_t GetMaxPos | ( | void | ) | const |
Get the maximal position occupied by an elements in the container.
size_t GetNb | ( | void | ) | const |
Get the number of elements in the cursor.
- Attention
- Since a cursor has no idea of the number of non null elements in a cursor for the domain it covers, it must recompute it for each new assignment.
bool Begin | ( | void | ) | const |
Test if the begin of the cursor is reached.
bool End | ( | void | ) | const |
Test if the end of the cursor is reached.
bool IsAt | ( | size_t | idx | ) | const |
Test if the cursor is at a given index.
- Parameters
-
idx Index of the element.
void Next | ( | size_t | inc = 1 | ) |
Go to a given number of next elements. If the end is reached, go to the beginning.
- Parameters
-
inc Number 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
-
inc Number of elements to go to.
C* operator() | ( | void | ) | const |
- Returns
- the current element.
Field Documentation
|
protected |
This variable is used to go through the container.
|
protected |
This variable is used to see if the end of the container is reached.
|
protected |
The array of pointers for the elements.
|
protected |
The number of elements in the container.
|
protected |
The number of elements in the cursor.
|
protected |
The first position in the array handled by the cursor.
|
protected |
The last position in the array handled by the cursor.