LibRCG  3.1.1
iterator.h File Reference

Implementation of an iterator. More...

Go to the source code of this file.

Data Structures

struct  SIterator
 Iterator structure. More...
 

Typedefs

typedef SIteratorIterator
 Iterator definition. More...
 

Functions

Iterator newIt (int size)
 Creates an iterator. More...
 
void itDelete (Iterator it)
 Deletes an iterator. More...
 
int itAdd (Iterator it, void *val)
 Adds an element to an iterator. More...
 
int itNext (Iterator it, void **val)
 Provides the next element of an iterator. More...
 
int itHasNext (Iterator it)
 Checks if there is "next". More...
 
int itPrev (Iterator it, void **val)
 Provides the previous element of an iterator. More...
 
int itHasPrev (Iterator it)
 Checks if there is "previous". More...
 
int itAt (Iterator it, int index, void **elem)
 Provides the element at the specified position of an iterator. More...
 
int itSetPos (Iterator it, int n)
 Sets the current position of an iterator. More...
 
int itGetPos (Iterator it)
 Provides the current position of an iterator. More...
 

Detailed Description

Implementation of an iterator.

Iterators contain a sequence of pointers to the elements to be iterated.

Author
Rui Carlos Gonçalves
Version
3.0.1
Date
08/2015

Definition in file iterator.h.

Typedef Documentation

typedef SIterator* Iterator

Iterator definition.

Definition at line 32 of file iterator.h.

Function Documentation

int itAdd ( Iterator  it,
void *  val 
)

Adds an element to an iterator.

In case the iterator is full, the element is not added.

Parameters
itthe iterator
valthe value to be added
Returns
0 if the value was added
1 if the iterator was full

Definition at line 44 of file iterator.c.

int itAt ( Iterator  it,
int  index,
void **  elem 
)

Provides the element at the specified position of an iterator.

Verifica qual o elemento numa determinada posição do array de valores de um iterador.

Parameters
itthe iterator
indexthe position
elempointer were the element at the specified position will be put
Returns
0 if there was an element at the specified position
1 otherwise

Definition at line 110 of file iterator.c.

void itDelete ( Iterator  it)

Deletes an iterator.

Parameters
itthe iterator to be deleted

Definition at line 36 of file iterator.c.

int itGetPos ( Iterator  it)

Provides the current position of an iterator.

Parameters
itthe iterator
Returns
the current position of the iterator

Definition at line 137 of file iterator.c.

int itHasNext ( Iterator  it)

Checks if there is "next".

Parameters
itthe iterator.
Returns
1 if there is "next"
0 otherwise

Definition at line 76 of file iterator.c.

int itHasPrev ( Iterator  it)

Checks if there is "previous".

Parameters
itthe iterator.
Returns
1 if there is "previous"
0 otherwise

Definition at line 102 of file iterator.c.

int itNext ( Iterator  it,
void **  val 
)

Provides the next element of an iterator.

Parameters
itthe iterator
valpointer were the next element should be put
Returns
0 if the next element was provided
1 otherwise

Definition at line 58 of file iterator.c.

int itPrev ( Iterator  it,
void **  val 
)

Provides the previous element of an iterator.

Parameters
itthe iterator
valpointer were the previous element should be put
Returns
0 if the previous element was provided
1 otherwise

Definition at line 84 of file iterator.c.

int itSetPos ( Iterator  it,
int  n 
)

Sets the current position of an iterator.

It changes the value of field pos of an iterator (if the value og n is valid).

Parameters
itthe iterator
nthe new position
Returns
-1 if the value of the new position is invalid
the old position otherwise

Definition at line 124 of file iterator.c.

Iterator newIt ( int  size)

Creates an iterator.

Parameters
sizethe capacity
Returns
NULL if an error occurred
the new iterator otherwise

Definition at line 12 of file iterator.c.

LibRCG © 2004-2015   Rui Carlos Gonçalves