pelib
2.0.0
|
00001 /* 00002 * iterator.h 00003 * 00004 * Created on: 5 Sep 2011 00005 * Copyright 2011 Nicolas Melot 00006 * 00007 * This file is part of pelib. 00008 * 00009 * pelib is free software: you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation, either version 3 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * pelib is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with pelib. If not, see <http://www.gnu.org/licenses/>. 00021 * 00022 */ 00023 00024 #include <pelib/template.h> 00025 #if PELIB_CONCAT_2(DONE_iterator_, ITERATOR_T) == 0 00026 00027 #define iterator(elem) PELIB_CONCAT_2(iterator_, elem) 00028 #define iterator_t(elem) PELIB_CONCAT_2(iterator(elem), _t) 00029 00030 #define pelib_iterator_next(value) PELIB_CONCAT_3(pelib_, iterator(value), _next) 00031 #define pelib_iterator_read(value) PELIB_CONCAT_3(pelib_, iterator(value), _read) 00032 #define pelib_iterator_distance(value) PELIB_CONCAT_3(pelib_, iterator(value), _distance) 00033 00035 struct iterator(ITERATOR_T) 00036 { 00037 struct iterator(ITERATOR_T) *previous, *next; 00038 ITERATOR_T value; 00039 }; 00040 typedef struct iterator(ITERATOR_T) iterator_t(ITERATOR_T); 00041 00042 iterator_t(ITERATOR_T)* 00043 pelib_iterator_next(ITERATOR_T)(iterator_t(ITERATOR_T)*); 00044 00045 ITERATOR_T 00046 pelib_iterator_read(ITERATOR_T)(iterator_t(ITERATOR_T)*); 00047 00048 size_t 00049 pelib_iterator_distance(ITERATOR_T)(iterator_t(ITERATOR_T) *start, iterator_t(ITERATOR_T) *stop); 00050 00051 #define STRUCT_T iterator_t(ITERATOR_T) 00052 #include <pelib/structure.h> 00053 00054 #endif /* ITERATOR_H_ */ 00055 00056 // Make sure the symbol does not propagate any further 00057 #undef ITERATOR_T