Program Listing for File iter.h
↰ Return to documentation for file (rcsw/ds/iter.h
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include "rcsw/ds/ds.h"
/*******************************************************************************
* Type Definitions
******************************************************************************/
enum ds_iter_type {
ekITER_FORWARD,
ekITER_BACKWARD,
};
/*******************************************************************************
* Structure Definitions
******************************************************************************/
struct ds_iterator {
union {
struct darray *arr;
struct rbuffer *rb;
struct llist *list;
struct llist_node *curr;
};
enum ds_tag tag;
enum ds_iter_type type;
int index;
bool_t (*classify)(void *e);
};
/*******************************************************************************
* API Functions
******************************************************************************/
BEGIN_C_DECLS
RCSW_API void *ds_iter_next(struct ds_iterator *iter);
RCSW_API struct ds_iterator * ds_iter_init(void *ds,
enum ds_tag tag,
enum ds_iter_type type);
RCSW_API struct ds_iterator * ds_filter_init(void *ds,
enum ds_tag tag,
bool_t (*f)(void *e));
END_C_DECLS