00001
00002
00003
00004
00005
00006
00007
00019 #ifndef __NUSMV_CORE_UTILS_BI_MAP_H__
00020 #define __NUSMV_CORE_UTILS_BI_MAP_H__
00021
00022 #if HAVE_CONFIG_H
00023 # include "nusmv-config.h"
00024 #endif
00025
00031 #define BI_MAP_FAST_ITERATOR
00032
00033 #include "nusmv/core/utils/defs.h"
00034 #include "nusmv/core/utils/NodeList.h"
00035 #include "nusmv/core/utils/assoc.h"
00036 #include "nusmv/core/node/node.h"
00037
00044 typedef struct BiMap_TAG* BiMap_ptr;
00045
00046 #ifndef BI_MAP_FAST_ITERATOR
00047 typedef struct BiMapIter_TAG{
00048 st_generator gen;
00049 char* key_p;
00050 char* value_p;
00051 int end;
00052 } BiMapIter;
00053 #else
00054 typedef struct BiMapIter_TAG{
00055 ListIter_ptr d_iter;
00056 ListIter_ptr c_iter;
00057 } BiMapIter;
00058 #endif
00059
00066 #define BI_MAP(self) \
00067 ((BiMap_ptr) self)
00068
00074 #define BI_MAP_CHECK_INSTANCE(self) \
00075 (nusmv_assert(BI_MAP(self) != BI_MAP(NULL)))
00076
00082 #define BI_MAP_FOREACH(self, iter) \
00083 for (BiMap_gen_iter(self, &iter); \
00084 !BiMap_iter_is_end(self, &iter); \
00085 BiMap_iter_next(self, &iter)) \
00086
00087
00088
00089
00090
00091
00100 BiMap_ptr BiMap_create(void);
00101
00110 void BiMap_destroy(BiMap_ptr self);
00111
00120 void BiMap_put(BiMap_ptr self, node_ptr domain_element, node_ptr codomain_element);
00121
00128 node_ptr BiMap_get(BiMap_ptr self, node_ptr domain_element);
00129
00136 node_ptr BiMap_inverse_get(BiMap_ptr self, node_ptr codomain_element);
00137
00145 boolean BiMap_domain_contains(BiMap_ptr self, node_ptr domain_element);
00146
00154 boolean BiMap_codomain_contains(BiMap_ptr self, node_ptr codomain_element);
00155
00162 unsigned BiMap_size(BiMap_ptr self);
00163
00170 boolean BiMap_is_empty(BiMap_ptr self);
00171
00178 void BiMap_clear(BiMap_ptr self);
00179
00180
00181
00188 void BiMap_gen_iter(BiMap_ptr self, BiMapIter* iter);
00189
00196 boolean BiMap_iter_is_end(BiMap_ptr self, BiMapIter* iter);
00197
00204 void BiMap_iter_next(BiMap_ptr self, BiMapIter* iter);
00205
00212 node_ptr BiMap_iter_get_domain_element(BiMap_ptr self,
00213 BiMapIter* iter);
00214
00221 node_ptr BiMap_iter_get_codomain_element(BiMap_ptr self,
00222 BiMapIter* iter);
00223
00224
00225
00236 NodeList_ptr BiMap_domain(BiMap_ptr self);
00237
00248 NodeList_ptr BiMap_codomain(BiMap_ptr self);
00249
00259 hash_ptr BiMap_map(BiMap_ptr self);
00260
00270 hash_ptr BiMap_inverse_map(BiMap_ptr self);
00271
00272 #endif