Rename method _it_to_p into _it_until_p. Add method _it_while_p

This commit is contained in:
Patrick Pelissier committed 2019-07-03 18:57:24 +02:00
1 parent ec7b5dd120
commit 37f3cd6a72
5 files changed
+50 -7

No files matched your search

+10 -2
View File
@@ -2634,10 +2634,14 @@ Return true if 'it' references no longer a valid element.
Return true if 'it' references the last element or is no longer valid.
##### bool name\_to\_p(const name\it_\_t it, const type data)
##### bool name\_it\_until\_p(const name\it_\_t it, const type data)
Return true if 'it' references an element that is greater or equal than 'data'.
##### bool name\_it\_while\_p(const name\it_\_t it, const type data)
Return true if 'it' references an element that is lower or equal than 'data'.
##### void name\_next(name\it_\_t it)
Update the iterator 'it' to the next element.
@@ -2893,10 +2897,14 @@ lower of equal than 'data' or the first element is there is none.
Return true if 'it' references no longer a valid element.
##### bool name\_to\_p(const name\_it_\_t it, const type data)
##### bool name\_it\_until\_p(const name\_it_\_t it, const type data)
Return true if 'it' references an element that is greater or equal than 'data'.
##### bool name\_it\_while\_p(const name\_it_\_t it, const type data)
Return true if 'it' references an element that is lower or equal than 'data'.
##### bool name\_it\_equal\_p(const name\_it_\_t it1, const name\_it_\_t it1)
Return true if both iterators reference the same object.
+2
View File
@@ -37,3 +37,5 @@ V0.2.*: * worker_start takes a 'worker_t' as an additional parameter
V0.3.*: * Remove B+TREE _remove method as it has been deprecated (use _erase instead)
* Remove DICT _remove method as it has been deprecated (use _erase instead)
* Make _it_to_p method of B+TREE / RB-TREE as deprecated (uses _it_until_p instead ).
+17 -1
View File
@@ -864,7 +864,7 @@
} \
\
static inline bool \
M_C(name, _it_to_p)(it_t it, key_t const key) \
M_C(name, _it_until_p)(it_t it, key_t const key) \
{ \
assert (it != NULL); \
node_t n = it->node; \
@@ -873,6 +873,22 @@
return (cmp >= 0); \
} \
\
static inline bool \
M_C(name, _it_while_p)(it_t it, key_t const key) \
{ \
assert (it != NULL); \
node_t n = it->node; \
if (it->idx >= -n->num) return true; \
int cmp = M_CALL_CMP(key_oplist, n->key[it->idx], key); \
return (cmp <= 0); \
} \
\
static inline bool M_ATTR_DEPRECATED \
M_C(name, _it_to_p)(it_t it, key_t const key) \
{ \
return M_C(name, _it_until_p)(it, key); \
} \
\
static inline value_t * \
M_C(name, _min)(const tree_t b) \
{ \
+18 -1
View File
@@ -513,7 +513,7 @@ typedef enum {
} \
\
static inline bool \
M_C(name, _it_to_p)(it_t it, type const data) \
M_C(name, _it_until_p)(it_t it, type const data) \
{ \
assert (it != NULL); \
if (it->cpt == 0) return true; \
@@ -523,6 +523,23 @@ typedef enum {
return (cmp >= 0); \
} \
\
static inline bool \
M_C(name, _it_while_p)(it_t it, type const data) \
{ \
assert (it != NULL); \
if (it->cpt == 0) return true; \
assert (it->cpt > 0 && it->cpt < RBTREEI_MAX_STACK); \
node_t *n = it->stack[it->cpt-1]; \
int cmp = M_CALL_CMP(oplist, n->data, data); \
return (cmp <= 0); \
} \
\
static inline bool M_ATTR_DEPRECATED \
M_C(name, _it_to_p)(it_t it, type const data) \
{ \
return M_C(name, _it_until_p)(it, data); \
} \
\
static inline type * \
M_C(name, _min)(const tree_t tree) \
{ \
+3 -3
View File
@@ -282,7 +282,7 @@ static void test5(void)
assert (btree_it_equal_p(it, it2));
i = 500;
for(btree_it_from(it, b, 500); !btree_it_to_p(it, 600); btree_next(it)) {
for(btree_it_from(it, b, 500); !btree_it_until_p(it, 600); btree_next(it)) {
const btree_type_t *item = btree_cref(it);
assert (*item->key_ptr == i);
assert (*item->value_ptr == 1000*i);
@@ -292,7 +292,7 @@ static void test5(void)
btree_erase (b, 500);
i = 501;
for(btree_it_from(it, b, 500); !btree_it_to_p(it, 600); btree_next(it)) {
for(btree_it_from(it, b, 500); !btree_it_until_p(it, 600); btree_next(it)) {
const btree_type_t *item = btree_cref(it);
assert (*item->key_ptr == i);
assert (*item->value_ptr == 1000*i);
@@ -302,7 +302,7 @@ static void test5(void)
btree_it_from(it, b, 1000);
assert (btree_end_p(it));
assert (btree_it_to_p(it, 1001));
assert (btree_it_until_p(it, 1001));
btree_clear(b);
}