Node Cursor. More...

#include <rtree.h>

Public Member Functions

 RNodeCursor (void)
 
 RNodeCursor (const RNodeCursor< T, N > &src)
 
 RNodeCursor (const N *node, size_t min=0, size_t max=SIZE_MAX)
 
 RNodeCursor (const T &root, size_t min=0, size_t max=SIZE_MAX)
 
RNodeCursor< T, N > & operator= (const RNodeCursor< T, N > &src)
 
void Set (const T &root, size_t min=0, size_t max=SIZE_MAX)
 
void Set (const N *node, size_t min=0, size_t max=SIZE_MAX)
 
void Clear (void)
 
void Start (void)
 
void StartFromEnd (void)
 
void GoTo (size_t idx)
 
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)
 
N * operator() (void) const
 

Protected Attributes

const T * Root
 
const N * Node
 
N * Current
 
size_t ActPtr
 
size_t NbPtr
 
size_t FirstPtr
 
size_t LastPtr
 

Detailed Description

template<class T, class N>
singleton R::RNodeCursor< T, N >

Node Cursor.

This class represent a cursor iterating childs of a given RNode of a RTree.

Parameters
TClass of the tree.
NClass of the node.
Attention
When an element is added or removed from the node parsed by the cursor, the cursor is not valid anymore.

Here is an example of a cursor used:

int example(RContainer<RString,true,true>& c)
{
RCursor<MyElement> Cur(c);
for(Cur.Start();!Cur.End();Cur.Next())
Cur()->DoSomething(2.3);
RCursor<MyElement> Cur2(0,1); // Treat the first two elements
for(Cur2.Start();!Cur2.End();Cur2.Next())
Cur2()->DoSomething(2.3);
}

Constructor & Destructor Documentation

RNodeCursor ( void  )

Construct the cursor.

RNodeCursor ( const RNodeCursor< T, N > &  src)

Construct the cursor.

Parameters
srcSource container.
RNodeCursor ( const N *  node,
size_t  min = 0,
size_t  max = SIZE_MAX 
)

Construct the cursor.

Parameters
nodeNode to iterate.
minMinimum position of the elements to iterate.
maxMaximum position of the elements to iterate (included max). If SIZE_MAX, iterate until the end of the container.
RNodeCursor ( const T &  root,
size_t  min = 0,
size_t  max = SIZE_MAX 
)

Construct the cursor.

Parameters
rootRoot node to iterate.
minMinimum position of the elements to iterate.
maxMaximum position of the elements to iterate (included max). If SIZE_MAX, iterate until the end of the container.

Member Function Documentation

RNodeCursor<T,N>& operator= ( const RNodeCursor< T, N > &  src)

Assignment operator using a "Cursor".

Parameters
srcSource container.
void Set ( const T &  root,
size_t  min = 0,
size_t  max = SIZE_MAX 
)

Set the container.

Parameters
rootTop node to iterate.
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.
void Set ( const N *  node,
size_t  min = 0,
size_t  max = SIZE_MAX 
)

Set the container.

Parameters
nodeNode to iterate.
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.
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 element of the cursor.

Parameters
idxIndex of the element to get.
size_t GetPos ( void  ) const

Return the actual position in the cursor.

size_t GetMaxPos ( void  ) const
Returns
the maximal position occupied by an elements in the container.
size_t GetNb ( void  ) const

Return the number of elements in the cursor.

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
idxIndex 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
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.
N* operator() ( void  ) const
Returns
the current element.

Field Documentation

const T* Root
protected

Root node iterated;

const N* Node
protected

Node iterated;

N* Current
protected

This variable is used to go through the node.

size_t ActPtr
protected

This variable is used to see if the end of the node is reached.

size_t NbPtr
protected

The number of elements in the node.

size_t FirstPtr
protected

The first position handled by the cursor.

size_t LastPtr
protected

The last position handled by the cursor.