tupperware: list: add 'empty' predicate
This commit is contained in:
parent
5dd1f5b739
commit
ad1f130deb
|
@ -64,6 +64,7 @@ struct list_node *list_node_safe_detach(struct list_node **at);
|
||||||
struct list_node *list_pop_front(struct list *list);
|
struct list_node *list_pop_front(struct list *list);
|
||||||
struct list_node *list_pop_back(struct list *list);
|
struct list_node *list_pop_back(struct list *list);
|
||||||
|
|
||||||
|
bool list_empty(const struct list *list);
|
||||||
size_t list_length(const struct list *list);
|
size_t list_length(const struct list *list);
|
||||||
|
|
||||||
void list_node_concat(struct list_node *begin, struct list_node *end);
|
void list_node_concat(struct list_node *begin, struct list_node *end);
|
||||||
|
|
|
@ -108,6 +108,12 @@ struct list_node *list_pop_back(struct list *list) {
|
||||||
return list_pop_front(list);
|
return list_pop_front(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool list_empty(const struct list *list) {
|
||||||
|
if (!list)
|
||||||
|
return true;
|
||||||
|
return list->head == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
size_t list_length(const struct list *list) {
|
size_t list_length(const struct list *list) {
|
||||||
if (!list || !list->head)
|
if (!list || !list->head)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue