cdcontainers  0.1.1
Library of data containers and collections for C programming language.
Functions
Cdc_map_iter

The cdc_map_iter is a struct and functions that provide a map iterator. More...

Functions

enum cdc_stat cdc_map_iter_ctor (struct cdc_map *m, struct cdc_map_iter *it)
 Constructs a map iterator. Should be called for each new iterator. More...
 
static void cdc_map_iter_dtor (struct cdc_map_iter *it)
 Destroys the iterator. It should be called after the iterator is no longer needed. Releases resources. More...
 
static enum cdc_iterator_type cdc_map_iter_type (struct cdc_map_iter *it)
 Returns a type of iterator. More...
 
static void cdc_map_iter_next (struct cdc_map_iter *it)
 Advances the iterator to the next element in the map. More...
 
static void cdc_map_iter_prev (struct cdc_map_iter *it)
 Advances the iterator to the previous element in the map. More...
 
static bool cdc_map_iter_has_next (struct cdc_map_iter *it)
 Returns true if there is at least one element ahead of the iterator, i.e. the iterator is not at the back of the container; otherwise returns false. More...
 
static bool cdc_map_iter_has_prev (struct cdc_map_iter *it)
 Returns true if there is at least one element behind the iterator, i.e. the iterator is not at the front of the container; otherwise returns false. More...
 
static void * cdc_map_iter_key (struct cdc_map_iter *it)
 Returns an item's key. More...
 
static void * cdc_map_iter_value (struct cdc_map_iter *it)
 Returns an item's value. More...
 
static struct cdc_pair cdc_map_iter_key_value (struct cdc_map_iter *it)
 Returns a pair, where first - key, second - value. More...
 
static bool cdc_map_iter_is_eq (struct cdc_map_iter *it1, struct cdc_map_iter *it2)
 Returns false if the iterator |it1| equal to the iterator |it2|, otherwise returns false. More...
 

Detailed Description

The cdc_map_iter is a struct and functions that provide a map iterator.

Function Documentation

◆ cdc_map_iter_ctor()

enum cdc_stat cdc_map_iter_ctor ( struct cdc_map m,
struct cdc_map_iter it 
)

Constructs a map iterator. Should be called for each new iterator.

Parameters
[in]t- cdc_map
[out]it- iterator

Example:

struct cdc_map *map = NULL;
...
if (cdc_map_iter_ctor(map, &it) != CDC_STATUS_OK) {
// handle error
}
cdc_map_begin(map, &it);
while (cdc_map_iter_has_next(&it)) {
void *value = cdc_map_iter_value(&it);
...
}

◆ cdc_map_iter_dtor()

static void cdc_map_iter_dtor ( struct cdc_map_iter it)
inlinestatic

Destroys the iterator. It should be called after the iterator is no longer needed. Releases resources.

Parameters
[in]it- iterator

◆ cdc_map_iter_type()

static enum cdc_iterator_type cdc_map_iter_type ( struct cdc_map_iter it)
inlinestatic

Returns a type of iterator.

Parameters
[in]it- iterator
Returns
a type of iterator.

◆ cdc_map_iter_next()

static void cdc_map_iter_next ( struct cdc_map_iter it)
inlinestatic

Advances the iterator to the next element in the map.

Parameters
[in]it- iterator

◆ cdc_map_iter_prev()

static void cdc_map_iter_prev ( struct cdc_map_iter it)
inlinestatic

Advances the iterator to the previous element in the map.

Parameters
[in]it- iterator

◆ cdc_map_iter_has_next()

static bool cdc_map_iter_has_next ( struct cdc_map_iter it)
inlinestatic

Returns true if there is at least one element ahead of the iterator, i.e. the iterator is not at the back of the container; otherwise returns false.

Parameters
[in]it- iterator
Returns
true if there is at least one element ahead of the iterator, i.e. the iterator is not at the back of the container; otherwise returns false.

◆ cdc_map_iter_has_prev()

static bool cdc_map_iter_has_prev ( struct cdc_map_iter it)
inlinestatic

Returns true if there is at least one element behind the iterator, i.e. the iterator is not at the front of the container; otherwise returns false.

Parameters
[in]it- iterator
Returns
true if there is at least one element behind the iterator, i.e. the iterator is not at the front of the container; otherwise returns false.

◆ cdc_map_iter_key()

static void* cdc_map_iter_key ( struct cdc_map_iter it)
inlinestatic

Returns an item's key.

Parameters
[in]it- iterator
Returns
the item's key.

◆ cdc_map_iter_value()

static void* cdc_map_iter_value ( struct cdc_map_iter it)
inlinestatic

Returns an item's value.

Parameters
[in]it- iterator
Returns
the item's value.

◆ cdc_map_iter_key_value()

static struct cdc_pair cdc_map_iter_key_value ( struct cdc_map_iter it)
static

Returns a pair, where first - key, second - value.

Parameters
[in]it- iterator
Returns
pair, where first - key, second - value.

◆ cdc_map_iter_is_eq()

static bool cdc_map_iter_is_eq ( struct cdc_map_iter it1,
struct cdc_map_iter it2 
)
inlinestatic

Returns false if the iterator |it1| equal to the iterator |it2|, otherwise returns false.

Parameters
[in]it1- iterator
[in]it2- iterator
Returns
false if the iterator |it1| equal to the iterator |it2|, otherwise returns false.