TaPAS  0.2
ccl-iterator.h
Go to the documentation of this file.
1 /*
2  * ccl-iterator.h -- A generic iterator interface
3  *
4  * This file is a part of the C Common Library (CCL) project.
5  *
6  * Copyright (C) 2010 CNRS UMR 5800 & Universit√© Bordeaux I (see AUTHORS file).
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the AltaRica Public License that comes with this
10  * package.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  */
16 
21 #ifndef __CCL_ITERATOR_H__
22 # define __CCL_ITERATOR_H__
23 
24 # include <ccl/ccl-common.h>
25 # include <ccl/ccl-protos.h>
26 
43 # define CCL_ITERATOR_TYPEDEF(_typename_,_eltype_) \
44 typedef struct ccl_iterator_ ## _typename_ ## _st _typename_; \
45 struct ccl_iterator_ ## _typename_ ## _st { \
46  int (*has_more_elements) (const _typename_ *i); \
47  _eltype_ (*next_element) (_typename_ *i); \
48  void (*delete_iterator) (_typename_ *i); \
49 }
50 
54 CCL_ITERATOR_TYPEDEF (ccl_pointer_iterator, void *);
55 
59 CCL_ITERATOR_TYPEDEF (ccl_int_iterator, int);
60 
67 # define ccl_iterator_has_more_elements(i) ((i)->has_more_elements (i))
68 
75 # define ccl_iterator_next_element(i) ((i)->next_element (i))
76 
81 # define ccl_iterator_delete(i) ((i)->delete_iterator (i))
82 
83 BEGIN_C_DECLS
84 
85 extern ccl_pointer_iterator *
86 ccl_iterator_crt_filter (ccl_pointer_iterator *base,
87  int (*accept) (void *obj, void *data),
88  void *data,
89  ccl_delete_proc *del);
90 
91 extern ccl_pointer_iterator *
92 ccl_iterator_crt_concat (ccl_pointer_iterator *i1, ccl_pointer_iterator *i2);
93 
94 extern ccl_pointer_iterator *
95 ccl_iterator_crt_sequence (int nb_iterators, ccl_pointer_iterator **iterators);
96 
97 END_C_DECLS
98 
99 #endif /* ! __CCL_ITERATOR_H__ */
Frequently used prototypes of generic functions.
#define CCL_ITERATOR_TYPEDEF(_typename_, _eltype_)
Macro-function used to define and declare a new iterator type.
Definition: ccl-iterator.h:43
void ccl_delete_proc(void *ptr)
Prototype of procedures used to release the resources allocated to the object pointed by ptr...
Definition: ccl-protos.h:44
Some useful and common macros.