pelib  2.0.0
include/pelib/set.h
Go to the documentation of this file.
00001 /*
00002  * set.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_set_, SET_T) == 0
00026 
00027 //#define ITERATOR_T SET_T
00028 //#include <pelib/iterator.h>
00029 
00030 #define set(elem) PELIB_CONCAT_2(set_, elem)
00031 #define set_t(elem) PELIB_CONCAT_2(set(elem), _t)
00032 
00033 #define pelib_set_first(elem) PELIB_CONCAT_3(pelib_, set(elem), _first)
00034 #define pelib_set_last(elem) PELIB_CONCAT_3(pelib_, set(elem), _last)
00035 #define pelib_set_insert(elem) PELIB_CONCAT_3(pelib_, set(elem), _insert)
00036 #define pelib_set_find(elem) PELIB_CONCAT_3(pelib_, set(elem), _find)
00037 #define pelib_set_compare(elem) PELIB_CONCAT_3(pelib_, set(elem), _compare)
00038 
00040 struct set(SET_T)
00041 {
00042         iterator_t(SET_T) *first, *last, *middle; 
00043 };
00044 typedef struct set(SET_T) set_t(SET_T);
00045 
00046 #define STRUCT_T set_t(SET_T)
00047 #include <pelib/structure.h>
00048 
00049 /* Returns the first element in set */
00050 SET_T*
00051 pelib_set_first(SET_T)(set_t(SET_T)*);
00052 
00053 /* Returns the first element in set */
00054 SET_T*
00055 pelib_set_last(SET_T)(set_t(SET_T)*);
00056 
00057 /* Places an element in set */
00058 int
00059 pelib_set_insert(SET_T)(set_t(SET_T)*, SET_T);
00060 
00061 /* Find an element in set */
00062 SET_T*
00063 pelib_set_find(SET_T)(set_t(SET_T)*, SET_T);
00064 
00068 int
00069 pelib_set_compare(SET_T)(set_t(SET_T)* a1, set_t(SET_T)* a2);
00070 
00071 #endif /* SET_H_ */
00072 
00073 // Make sure the symbol does not propagate any further
00074 #undef SET_T