Rename operator TEST_EMPTY into EMPTY_P to be compliant with iterator operator

This commit is contained in:
Patrick Pelissier committed 2021-01-07 22:13:10 +01:00
1 parent 6ccc81fd92
commit 1b4c608087
15 files changed
+31 -30

No files matched your search

+8 -7
View File
@@ -519,6 +519,8 @@ Other documented operators are:
* INIT\_WITH(obj, ...): Initialize the object 'obj' with a variable set of arguments. Arguments can be of different types and is up to the method to decide how to initialize the object based on this set. This is used in the M\_LET macro to initialize objects with the given values.
* SWAP(objd, objc): Swap the states of the object 'objc' and the object 'objd'.
* CLEAN(obj): Empty the container from all its objects. Nearly like CLEAR except that the container 'obj' remains initialized (but empty).
* EMPTY\_P(obj) --> bool: Test if the object is empty (true) or not.
* GET\_SIZE (container) --> size\_t: Return the number of elements in the container.
* HASH (obj) --> size_t: return a hash of the object (not a secure hash but one that is usable for a hash table). Default is performing a hash of the memory representation of the object. This default implementation is invalid if the object holds pointer to other objects.
* EQUAL(obj1, obj2) --> bool: Compare the object for equality. return true if both objects are equal, false otherwise. Default is using the C comparison operator. The method may be called with OOR object for the Open Addressing dictionary (in which case it shall return false).
* CMP(obj1, obj2) --> int: Provide a complete order the objects. return a negative integer if obj1 < obj2, 0 if obj1 = obj2, a positive integer otherwise. Default is C comparison operator.
@@ -530,7 +532,6 @@ Other documented operators are:
* SET\_KEY (container, key, object): Associate the key 'key' to the value object 'object' in the given container.
* GET\_SET\_KEY (container, key) --> &obj: return a pointer to the value object within the container associated to the key 'key' or create a new object in the container, associate it to the key 'key' (with default initialization) and return its pointer. The pointer to the object remains valid until any modification of the container. The returned pointer is therefore never NULL.
* ERASE\_KEY (container, key) --> bool: Erase the object associated to the key 'key' within the container. Return true if successful, false if the key is not found.
* GET\_SIZE (container) --> size_t: Return the number of elements in the container.
* PUSH(container, obj) : Push 'object' into 'container'. How and where it is pushed is container dependent.
* POP(&obj, container) : Pop an object from 'container' and save it in the initialized object '*obj' if obj is not NULL (giving back the ownership to the caller). Which object is popped is container dependent. The container shall have at least one object.
* PUSH_MOVE(container, &obj) : Push and move the object '*obj' into 'container'. How it is pushed is container dependent. '*obj' is cleared afterward and shall not be used anymore.
@@ -4525,7 +4526,7 @@ This method is only defined if the base container exports the SWAP operator.
##### bool name\_empty\_p(const name\_t concurrent)
Return true if the container is empty, false otherwise.
This method is only defined if the base container exports the TEST\_EMPTY operator.
This method is only defined if the base container exports the EMPTY\_P operator.
##### void name\_set\_at(name\_t concurrent, key\_t key, value\_t value)
@@ -4561,9 +4562,9 @@ This method is only defined if the base container exports the PUSH operator.
Pop data from the container and set it in '*data'.
There shall be at least one data to pop.
Testing with TEST_EMPTY before calling this function is not enough
Testing with the operator EMPTY\_P before calling this function is not enough
as there can be some concurrent scenario where another thread pop the last value.
It is highly recommending to use name\_pop\_blocking instead which is safer.
name\_pop\_blocking should be used instead.
This method is only defined if the base container exports the POP operator.
##### void name\_push\_move(name\_t concurrent, subtype\_t data)
@@ -4575,7 +4576,7 @@ This method is only defined if the base container exports the PUSH\_MOVE operato
##### void name\_pop\_move(subtype\_t *data, name\_t concurrent)
Pop data from the container and initialize '*data' with it.
It is highly recommending to use name\_pop\_move\_blocking instead which is safer.
name\_pop\_move\_blocking should be used instead (See name\_pop for details).
This method is only defined if the base container exports the POP\_MOVE operator.
##### void name\_get\_str(string\_t str, name\_t concurrent, bool append)
@@ -4621,7 +4622,7 @@ If the container is not empty, it sets '*data' and return true.
Otherwise if blocking is true, it waits for the data to be pushed.
After the wait, it sets '*data' to it and returns true.
Otherwise if blocking is false, it returns false.
This method is only defined if the base container exports the POP and TEST\_EMPTY operators.
This method is only defined if the base container exports the POP and EMPTY\_P operators.
##### bool name\_pop\_move\_blocking(type_t *data, name\_t concurrent, bool blocking)
@@ -4630,7 +4631,7 @@ If the container is not empty, it initializes & sets '*data' and return true.
Otherwise if blocking is true, it waits for the data to be pushed.
After the wait, it initializes & sets '*data' to it and returns true.
Otherwise if blocking is false, it returns false (*data remains uninitialized!).
This method is only defined if the base container exports the POP\_MOVE and TEST\_EMPTY operators.
This method is only defined if the base container exports the POP\_MOVE and EMPTY\_P operators.
##### size\_t name\_hash(name\_t concurrent)
+1 -1
View File
@@ -88,7 +88,7 @@
,SWAP(M_C(name, _swap)) \
,TYPE(M_C(name,_ct)) \
,SUBTYPE(M_C(name, _subtype_ct)) \
,TEST_EMPTY(M_C(name,_empty_p)) \
,EMPTY_P(M_C(name,_empty_p)) \
,IT_TYPE(M_C(name,_it_ct)), \
,IT_FIRST(M_C(name,_it)) \
,IT_LAST(M_C(name,_it_last)) \
+1 -1
View File
@@ -776,7 +776,7 @@ bitset_clz(const bitset_t set)
,SWAP(bitset_swap) \
,TYPE(bitset_t) \
,SUBTYPE(bool) \
,TEST_EMPTY(bitset_empty_p), \
,EMPTY_P(bitset_empty_p), \
,GET_SIZE(bitset_size) \
,IT_TYPE(bitset_it_t) \
,IT_FIRST(bitset_it) \
+1 -1
View File
@@ -232,7 +232,7 @@
SWAP(M_C(name, _swap)), \
TYPE(M_C(name,_ct)), \
SUBTYPE(M_C(name, _subtype_ct)), \
TEST_EMPTY(M_C(name,_empty_p)), \
EMPTY_P(M_C(name,_empty_p)), \
IT_TYPE(M_C(name, _it_ct)), \
IT_FIRST(M_C(name,_it)), \
IT_SET(M_C(name,_it_set)), \
+1 -1
View File
@@ -1170,7 +1170,7 @@ M_C(name, _init)(buffer_t v, size_t size) \
,PUSH(M_C(name,_push)) \
,POP(M_C(name,_pop)) \
,OPLIST(oplist) \
,TEST_EMPTY(M_C(name, _empty_p)), \
,EMPTY_P(M_C(name, _empty_p)), \
,GET_SIZE(M_C(name, _size)) \
)
+7 -7
View File
@@ -114,7 +114,7 @@
,TYPE(M_C(name,_ct)) \
,SUBTYPE(M_C(name, _subtype_ct)) \
,OPLIST(oplist) \
,M_IF_METHOD(TEST_EMPTY, oplist)(TEST_EMPTY(M_C(name,_empty_p)),) \
,M_IF_METHOD(EMPTY_P, oplist)(EMPTY_P(M_C(name,_empty_p)),) \
,M_IF_METHOD(GET_SIZE, oplist)(GET_SIZE(M_C(name,_size)),) \
,M_IF_METHOD(CLEAN, oplist)(CLEAN(M_C(name,_clean)),) \
,M_IF_METHOD(KEY_TYPE, oplist)(KEY_TYPE(M_GET_KEY_TYPE oplist),) \
@@ -432,13 +432,13 @@
} \
,) \
\
M_IF_METHOD(TEST_EMPTY, oplist)( \
M_IF_METHOD(EMPTY_P, oplist)( \
static inline bool \
M_C(name, _empty_p)(concurrent_t const out) \
{ \
CONCURRENTI_CONTRACT(out); \
M_C(name, _read_lock)(out); \
bool b = M_CALL_TEST_EMPTY(oplist, out->data); \
bool b = M_CALL_EMPTY_P(oplist, out->data); \
M_C(name, _read_unlock)(out); \
return b; \
} \
@@ -684,7 +684,7 @@
} \
,) \
\
M_IF_METHOD2(POP, TEST_EMPTY, oplist)( \
M_IF_METHOD2(POP, EMPTY_P, oplist)( \
static inline bool \
M_C(name, _pop_blocking)(M_GET_SUBTYPE oplist *p, concurrent_t out, bool blocking) \
{ \
@@ -693,7 +693,7 @@
bool ret = false; \
M_C(name, _write_lock)(out); \
while (true) { \
if (!M_CALL_TEST_EMPTY(oplist, out->data)) { \
if (!M_CALL_EMPTY_P(oplist, out->data)) { \
M_CALL_POP(oplist, p, out->data); \
ret = true; \
break; \
@@ -707,7 +707,7 @@
} \
,) \
\
M_IF_METHOD2(POP_MOVE, TEST_EMPTY, oplist)( \
M_IF_METHOD2(POP_MOVE, EMPTY_P, oplist)( \
static inline bool \
M_C(name, _pop_move_blocking)(M_GET_SUBTYPE oplist *p, concurrent_t out, bool blocking) \
{ \
@@ -716,7 +716,7 @@
bool ret = false; \
M_C(name, _write_lock)(out); \
while (true) { \
if (!M_CALL_TEST_EMPTY(oplist, out->data)) { \
if (!M_CALL_EMPTY_P(oplist, out->data)) { \
M_CALL_POP_MOVE(oplist, p, out->data); \
ret = true; \
break; \
+3 -3
View File
@@ -2355,7 +2355,7 @@ static inline size_t m_core_cstr_hash(const char str[])
#define M_IT_CREF_IT_CREF(a) ,a,
#define M_IT_REMOVE_IT_REMOVE(a) ,a,
#define M_IT_INSERT_IT_INSERT(a) ,a,
#define M_TEST_EMPTY_TEST_EMPTY(a) ,a,
#define M_EMPTY_P_EMPTY_P(a) ,a,
#define M_ADD_ADD(a) ,a,
#define M_SUB_SUB(a) ,a,
#define M_MUL_MUL(a) ,a,
@@ -2435,7 +2435,7 @@ static inline size_t m_core_cstr_hash(const char str[])
#define M_GET_IT_CREF(...) M_GET_METHOD(IT_CREF, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_IT_REMOVE(...) M_GET_METHOD(IT_REMOVE, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_IT_INSERT(...) M_GET_METHOD(IT_INSERT, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_TEST_EMPTY(...) M_GET_METHOD(TEST_EMPTY, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_EMPTY_P(...) M_GET_METHOD(EMPTY_P, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_ADD(...) M_GET_METHOD(ADD, M_ADD_DEFAULT, __VA_ARGS__)
#define M_GET_SUB(...) M_GET_METHOD(SUB, M_SUB_DEFAULT, __VA_ARGS__)
#define M_GET_MUL(...) M_GET_METHOD(MUL, M_MUL_DEFAULT, __VA_ARGS__)
@@ -2508,7 +2508,7 @@ static inline size_t m_core_cstr_hash(const char str[])
#define M_CALL_IT_CREF(oplist, ...) M_APPLY_API(M_GET_IT_CREF oplist, oplist, __VA_ARGS__)
#define M_CALL_IT_REMOVE(oplist, ...) M_APPLY_API(M_GET_IT_REMOVE oplist, oplist, __VA_ARGS__)
#define M_CALL_IT_INSERT(oplist, ...) M_APPLY_API(M_GET_IT_INSERT oplist, oplist, __VA_ARGS__)
#define M_CALL_TEST_EMPTY(oplist, ...) M_APPLY_API(M_GET_TEST_EMPTY oplist, oplist, __VA_ARGS__)
#define M_CALL_EMPTY_P(oplist, ...) M_APPLY_API(M_GET_EMPTY_P oplist, oplist, __VA_ARGS__)
#define M_CALL_ADD(oplist, ...) M_APPLY_API(M_GET_ADD oplist, oplist, __VA_ARGS__)
#define M_CALL_SUB(oplist, ...) M_APPLY_API(M_GET_SUB oplist, oplist, __VA_ARGS__)
#define M_CALL_MUL(oplist, ...) M_APPLY_API(M_GET_MUL oplist, oplist, __VA_ARGS__)
+1 -1
View File
@@ -995,7 +995,7 @@
,SWAP(M_C(name, _swap)) \
,TYPE(M_C(name,_ct)) \
,SUBTYPE(M_C(name, _subtype_ct)) \
,TEST_EMPTY(M_C(name,_empty_p)) \
,EMPTY_P(M_C(name,_empty_p)) \
,IT_TYPE(M_C(name,_it_ct)) \
,IT_FIRST(M_C(name,_it)) \
,IT_LAST(M_C(name,_it_last)) \
+2 -2
View File
@@ -1076,7 +1076,7 @@
CLEAN(M_C(name, _clean)), \
TYPE(M_C(name, _ct)), \
SUBTYPE(M_C(name, _subtype_ct)), \
TEST_EMPTY(M_C(name,_empty_p)), \
EMPTY_P(M_C(name,_empty_p)), \
IT_TYPE(M_C(name, _it_ct)), \
IT_FIRST(M_C(name,_it)), \
IT_SET(M_C(name, _it_set)), \
@@ -1131,7 +1131,7 @@
CLEAN(M_C(name, _clean)), \
TYPE(M_C(name, _ct)), \
SUBTYPE(M_C(name, _subtype_ct)), \
TEST_EMPTY(M_C(name,_empty_p)), \
EMPTY_P(M_C(name,_empty_p)), \
PUSH(M_C(name,_push)), \
KEY_TYPE(M_C(name, _key_ct)), \
VALUE_TYPE(M_C(name, _key_ct)), \
+1 -1
View File
@@ -104,7 +104,7 @@ typedef struct ilist_head_s {
TYPE(M_C(name,_ct)), \
CLEAN(M_C(name,_clean)), \
SUBTYPE(M_C(name,_subtype_ct)), \
TEST_EMPTY(M_C(name,_empty_p)), \
EMPTY_P(M_C(name,_empty_p)), \
IT_TYPE(M_C(name,_it_ct)), \
IT_FIRST(M_C(name,_it)), \
IT_SET(M_C(name,_it_set)), \
+1 -1
View File
@@ -103,7 +103,7 @@
SWAP(M_C(name, _swap)), \
TYPE(M_C(name,_ct)), \
SUBTYPE(M_C(name,_subtype_ct)), \
TEST_EMPTY(M_C(name,_empty_p)), \
EMPTY_P(M_C(name,_empty_p)), \
IT_TYPE(M_C(name, _it_ct)), \
IT_FIRST(M_C(name,_it)), \
IT_END(M_C(name,_it_end)), \
+1 -1
View File
@@ -90,7 +90,7 @@
,PUSH(M_C(name,_push)) \
,POP(M_C(name,_pop)) \
,OPLIST(oplist) \
,TEST_EMPTY(M_C(name, _empty_p)), \
,EMPTY_P(M_C(name, _empty_p)), \
,GET_SIZE(M_C(name, _size)) \
,IT_TYPE(M_C(name, _it_ct)), \
IT_FIRST(M_C(name,_it)), \
+1 -1
View File
@@ -86,7 +86,7 @@
SWAP(M_C(name, _swap)), \
TYPE(M_C(name,_ct)), \
SUBTYPE(M_C(name, _subtype_ct)), \
TEST_EMPTY(M_C(name,_empty_p)), \
EMPTY_P(M_C(name,_empty_p)), \
GET_SIZE(M_C(name, _size)), \
IT_TYPE(M_C(name, _it_ct)), \
IT_FIRST(M_C(name,_it)), \
+1 -1
View File
@@ -1791,7 +1791,7 @@ namespace m_string {
INIT_WITH(STRINGI_INIT_WITH), \
INIT_MOVE(string_init_move), MOVE(string_move), \
SWAP(string_swap), CLEAN(string_clean), \
TEST_EMPTY(string_empty_p), \
EMPTY_P(string_empty_p), \
CLEAR(string_clear), HASH(string_hash), EQUAL(string_equal_p), \
CMP(string_cmp), TYPE(string_t), \
PARSE_STR(string_parse_str), GET_STR(string_get_str), \
+1 -1
View File
@@ -741,7 +741,7 @@
CLEAR(M_C(name, _clear)), \
CLEAN(M_C(name, _clean)), \
TYPE(M_C(name,_ct)), \
TEST_EMPTY(M_C(name,_empty_p)), \
EMPTY_P(M_C(name,_empty_p)), \
M_IF_METHOD_ALL(HASH, __VA_ARGS__)(HASH(M_C(name, _hash)),), \
M_IF_METHOD_ALL(EQUAL, __VA_ARGS__)(EQUAL(M_C(name, _equal_p)),), \
M_IF_METHOD_ALL(GET_STR, __VA_ARGS__)(GET_STR(M_C(name, _get_str)),), \