diff --git a/m-array.h b/m-array.h index 939ab571..6a09f84f 100644 --- a/m-array.h +++ b/m-array.h @@ -60,6 +60,8 @@ ,SUBTYPE(M_C3(array_type_,name,_t)) \ ,IT_TYPE(M_C3(array_it_,name,_t)) \ ,IT_FIRST(M_C3(array_,name,_it)) \ + ,IT_LAST(M_C3(array_,name,_it_last)) \ + ,IT_END(M_C3(array_,name,_it_end)) \ ,IT_SET(M_C3(array_,name,_it_set)) \ ,IT_END_P(M_C3(array_,name,_end_p)) \ ,IT_LAST_P(M_C3(array_,name,_last_p)) \ @@ -466,6 +468,24 @@ it->array = v; \ } \ \ + static inline void \ + M_C3(array_, name, _it_last)(M_C3(array_it_,name,_t) it, \ + M_C3(array_, name, _t) v) \ + { \ + assert (it != NULL && v != NULL); \ + it->index = v->size - 1; \ + it->array = v; \ + } \ + \ + static inline void \ + M_C3(array_, name, _it_end)(M_C3(array_it_,name,_t) it, \ + M_C3(array_, name, _t) v) \ + { \ + assert (it != NULL && v != NULL); \ + it->index = v->size; \ + it->array = v; \ + } \ + \ static inline void \ M_C3(array_, name, _it_set)(M_C3(array_it_,name,_t) it, \ const M_C3(array_it_, name, _t) org) \ diff --git a/m-bitset.h b/m-bitset.h index 6256386c..654a2ac6 100644 --- a/m-bitset.h +++ b/m-bitset.h @@ -362,6 +362,22 @@ bitset_it_set(bitset_it_t it, const bitset_it_t itorg) it->set = itorg->set; } +static inline void +bitset_it_last(bitset_it_t it, bitset_t set) +{ + BITSETI_CONTRACT (set); + it->index = set->size-1; + it->set = set; +} + +static inline void +bitset_it_end(bitset_it_t it, bitset_t set) +{ + BITSETI_CONTRACT (set); + it->index = set->size; + it->set = set; +} + static inline bool bitset_end_p(const bitset_it_t it) { @@ -571,6 +587,8 @@ bitset_hash(const bitset_t dest) ,IT_TYPE(bitset_it_t) \ ,IT_FIRST(bitset_it) \ ,IT_SET(bitset_it_set) \ + ,IT_LAST(bitset_it_last) \ + ,IT_END(bitset_it_end) \ ,IT_END_P(bitset_end_p) \ ,IT_LAST_P(bitset_last_p) \ ,IT_EQUAL_P(bitset_it_equal_p) \ diff --git a/m-dict.h b/m-dict.h index efe1ab33..d52a2d3c 100644 --- a/m-dict.h +++ b/m-dict.h @@ -287,6 +287,15 @@ } \ \ static inline bool \ + M_C3(dict_, name, _it_end)(M_C3(dict_it_, name,_t) it, \ + M_C3(dict_, name,_t) d) \ + { \ + assert (it != NULL && d != NULL); \ + M_C3(list_dict_pair_, name, _it_end)(it->list_it, \ + *M_C3(array_list_dict_pair_, name, _get)(d->table, 0)); \ + } \ + \ + static inline bool \ M_C3(dict_, name, _end_p)(const M_C3(dict_it_, name,_t) it) \ { \ assert (it != NULL); \ @@ -450,6 +459,7 @@ IT_TYPE(M_C3(dict_it_,type,_t)), \ IT_FIRST(M_C3(dict_,type,_it)), \ IT_SET(M_C3(dict_, type, _it_set)), \ + IT_END(M_C3(dict_, type, _it_end)), \ IT_END_P(M_C3(dict_,type,_end_p)), \ IT_LAST_P(M_C3(dict_,type,_last_p)), \ IT_NEXT(M_C3(dict_,type,_next)), \ diff --git a/m-i-list.h b/m-i-list.h index 1d1b078f..f58c59a6 100644 --- a/m-i-list.h +++ b/m-i-list.h @@ -72,6 +72,8 @@ typedef struct ilist_head_s { IT_TYPE(M_C3(ilist_it_,name,_t)), \ IT_FIRST(M_C3(ilist_,name,_it)), \ IT_SET(M_C3(ilist_,name,_it_set)), \ + IT_LAST(M_C3(ilist_,name,_it_last)), \ + IT_END(M_C3(ilist_,name,_it_end)), \ IT_END_P(M_C3(ilist_,name,_end_p)), \ IT_LAST_P(M_C3(ilist_,name,_last_p)), \ IT_EQUAL_P(M_C3(ilist_,name,_it_equal_p)), \ @@ -242,6 +244,29 @@ typedef struct ilist_head_s { it->previous = cit->previous; \ } \ \ + static inline void \ + M_C3(ilist_, name, _it_last)(M_C3(ilist_it_, name,_t) it, \ + M_C3(ilist_, name,_t) list) \ + { \ + assert (it != NULL && list != NULL); \ + assert (list->name.next != NULL && list->name.next->next != NULL); \ + it->head = &list->name; \ + it->current = list->name.prev; \ + it->next = &list->name; \ + it->previous = list->name.prev->prev; \ + } \ + \ + static inline void \ + M_C3(ilist_, name, _it_end)(M_C3(ilist_it_, name,_t) it, \ + M_C3(ilist_, name,_t) list) \ + { \ + assert (it != NULL && list != NULL); \ + it->head = &list->name; \ + it->current = &list->name; \ + it->next = list->name.next; \ + it->previous = list->name.prev; \ + } \ + \ static inline bool \ M_C3(ilist_, name, _end_p)(const M_C3(ilist_it_, name,_t) it) \ { \ diff --git a/m-list.h b/m-list.h index fc1e7fa2..f84773b0 100644 --- a/m-list.h +++ b/m-list.h @@ -60,6 +60,7 @@ SUBTYPE(M_C3(list_type_,name,_t)), \ IT_TYPE(M_C3(list_it_,name,_t)), \ IT_FIRST(M_C3(list_,name,_it)), \ + IT_END(M_C3(list_,name,_it_end)), \ IT_SET(M_C3(list_,name,_it_set)), \ IT_END_P(M_C3(list_,name,_end_p)), \ IT_EQUAL_P(M_C3(list_,name,_it_equal_p)), \ @@ -222,6 +223,16 @@ it1[0].previous = it2[0].previous; \ } \ \ + static inline void \ + M_C3(list_, name, _it_end)(M_C3(list_it_, name,_t) it1, \ + const M_C3(list_, name,_t) v) \ + { \ + assert (it1 != NULL && v != NULL); \ + (void)v; /* unused */ \ + it1[0].l[0] = NULL; \ + it1[0].previous = NULL; \ + } \ + \ static inline bool \ M_C3(list_, name, _end_p)(const M_C3(list_it_, name,_t) v) \ { \ diff --git a/m-rbtree.h b/m-rbtree.h index 1d04a31e..39e065ba 100644 --- a/m-rbtree.h +++ b/m-rbtree.h @@ -64,6 +64,8 @@ IT_TYPE(M_C3(rbtree_it_,name,_t)), \ IT_FIRST(M_C3(rbtree_,name,_it)), \ IT_SET(M_C3(rbtree_,name,_it_set)), \ + IT_LAST(M_C3(rbtree_,name,_it_last)), \ + IT_END(M_C3(rbtree_,name,_it_end)), \ IT_END_P(M_C3(rbtree_,name,_end_p)), \ IT_LAST_P(M_C3(rbtree_,name,_last_p)), \ IT_EQUAL_P(M_C3(rbtree_,name,_it_equal_p)), \ @@ -369,6 +371,14 @@ typedef enum { M_C3(rbtreei_, name, _it)(it, tree, 1); \ } \ \ + static inline void \ + M_C3(rbtree_, name, _it_end)(M_C3(rbtree_it_, name,_t) it, \ + const M_C3(rbtree_, name,_t) tree) \ + { \ + assert (it != NULL && tree != NULL); \ + it->cpt = 0; \ + } \ + \ static inline bool \ M_C3(rbtree_, name, _end_p)(const M_C3(rbtree_it_, name,_t) it) \ { \