* Rename _slice into _splice.
* Rename _move_back into _splice_back to uniform the interface.
This commit is contained in:
1 parent
8e203fac5e
commit
76fc919ccb
4 files changed
+30
-28
No files matched your search
@@ -702,14 +702,15 @@ Insert 'x' after the position pointed by 'it' (which is an iterator of the list
|
||||
Remove the element 'it' from the list 'list'.
|
||||
After wise, 'it' points to the next element of the list.
|
||||
|
||||
##### void list\_name\_move\_back(list\_name\_t list1, list\_name\_t list2, list\_it\_name\_t it)
|
||||
##### void list\_name\_splice\_back(list\_name\_t list1, list\_name\_t list2, list\_it\_name\_t it)
|
||||
|
||||
Move the element pointed by 'it' (which is an iterator of 'list2') from the list 'list2' to the back position of 'list1'.
|
||||
After wise, 'it' points to the next element of 'list2'.
|
||||
|
||||
##### void list\_name\_slice(list\_name\_t list1, list\_name\_t list2)
|
||||
##### void list\_name\_splice(list\_name\_t list1, list\_name\_t list2)
|
||||
|
||||
Move all the element of 'list2' into 'list1".
|
||||
Move all the element of 'list2' into 'list1", moving the last element
|
||||
of 'list2' after the first element of 'list1'.
|
||||
After-wise, 'list2' is emptied.
|
||||
|
||||
##### void list\_name\_reverse(list\_name\_t list)
|
||||
|
||||
@@ -238,7 +238,7 @@
|
||||
assert( (hash & (new_size-1)) == (i + old_size)); \
|
||||
M_C3(list_dict_pair_,name,_t) *new_list = \
|
||||
M_C3(array_list_dict_pair_,name,_get)(map->table, i + old_size); \
|
||||
M_C3(list_dict_pair_,name,_move_back)(*new_list, *list, it); \
|
||||
M_C3(list_dict_pair_,name,_splice_back)(*new_list, *list, it); \
|
||||
} else { \
|
||||
M_C3(list_dict_pair_,name,_next)(it); \
|
||||
} \
|
||||
@@ -271,7 +271,7 @@
|
||||
assert ((hash & (new_size -1)) == i - new_size); \
|
||||
M_C3(list_dict_pair_,name,_t) *new_list = \
|
||||
M_C3(array_list_dict_pair_,name,_get)(map->table, i - new_size); \
|
||||
M_C3(list_dict_pair_,name,_move_back)(*new_list, *list, it); \
|
||||
M_C3(list_dict_pair_,name,_splice_back)(*new_list, *list, it); \
|
||||
} \
|
||||
} \
|
||||
/* Resize the dictionary */ \
|
||||
|
||||
@@ -379,27 +379,6 @@
|
||||
} \
|
||||
\
|
||||
static inline void \
|
||||
M_C3(list_, name, _move_back)(list_t nv, list_t ov, list_it_t it) \
|
||||
{ \
|
||||
assert (nv != NULL && ov != NULL && it != NULL && nv != ov); \
|
||||
assert(it[0].l[0] != NULL); \
|
||||
assert(M_C3(list_, name, _sublist_p)(ov, it)); \
|
||||
/* Remove it from ov */ \
|
||||
struct M_C3(list_, name, _s) *next = it[0].l[0]->next; \
|
||||
struct M_C3(list_, name, _s) *current = it[0].l[0]; \
|
||||
if (it->previous == NULL) { \
|
||||
*ov = next; \
|
||||
} else { \
|
||||
it->previous->next = next; \
|
||||
} \
|
||||
/* Update it to next element */ \
|
||||
it[0].l[0] = next; \
|
||||
/* Move current in nv */ \
|
||||
current->next = *nv; \
|
||||
*nv = current; \
|
||||
} \
|
||||
\
|
||||
static inline void \
|
||||
M_C3(list_, name, _set)(list_t list, const list_t org) \
|
||||
{ \
|
||||
assert (list != NULL && org != NULL); \
|
||||
@@ -447,8 +426,30 @@
|
||||
M_C3(list_, name, _init_move)(list, org); \
|
||||
} \
|
||||
\
|
||||
\
|
||||
static inline void \
|
||||
M_C3(list_, name, _slice)(list_t list1, list_t list2) \
|
||||
M_C3(list_, name, _splice_back)(list_t nv, list_t ov, list_it_t it) \
|
||||
{ \
|
||||
assert (nv != NULL && ov != NULL && it != NULL && nv != ov); \
|
||||
assert(it[0].l[0] != NULL); \
|
||||
assert(M_C3(list_, name, _sublist_p)(ov, it)); \
|
||||
/* Remove it from ov */ \
|
||||
struct M_C3(list_, name, _s) *next = it[0].l[0]->next; \
|
||||
struct M_C3(list_, name, _s) *current = it[0].l[0]; \
|
||||
if (it->previous == NULL) { \
|
||||
*ov = next; \
|
||||
} else { \
|
||||
it->previous->next = next; \
|
||||
} \
|
||||
/* Update it to next element */ \
|
||||
it[0].l[0] = next; \
|
||||
/* Move current in nv */ \
|
||||
current->next = *nv; \
|
||||
*nv = current; \
|
||||
} \
|
||||
\
|
||||
static inline void \
|
||||
M_C3(list_, name, _splice)(list_t list1, list_t list2) \
|
||||
{ \
|
||||
assert (list1 != NULL && list2 != NULL && list1 != list2); \
|
||||
struct M_C3(list_, name, _s) **update_list = list1; \
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ static void test_uint(void)
|
||||
assert (list_uint_size(v2) == 998);
|
||||
|
||||
list_uint_set (v, v2);
|
||||
list_uint_slice (v, v2);
|
||||
list_uint_splice (v, v2);
|
||||
assert (list_uint_empty_p(v) == false);
|
||||
assert (list_uint_empty_p(v2) == true);
|
||||
assert (list_uint_size(v) == 998*2);
|
||||
|
||||
Reference in new issue
Block a user