ds: list: update iterator interface
This commit is contained in:
@@ -1,37 +1,30 @@
|
||||
#ifndef BLUE_DS_LIST_H_
|
||||
#define BLUE_DS_LIST_H_
|
||||
|
||||
#include <blue/core/iterator.h>
|
||||
#include <blue/core/macros.h>
|
||||
#include <blue/core/status.h>
|
||||
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
#define B_TYPE_LIST (b_list_get_type())
|
||||
#define B_TYPE_LIST (b_list_get_type())
|
||||
#define B_TYPE_LIST_ITERATOR (b_list_iterator_get_type())
|
||||
|
||||
struct b_list_p;
|
||||
|
||||
B_DECLARE_TYPE(b_list);
|
||||
B_DECLARE_TYPE(b_list_iterator);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_list)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_list)
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_list_iterator)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_list_iterator)
|
||||
|
||||
typedef struct b_list_entry b_list_entry;
|
||||
|
||||
#define b_list_foreach(it, q) \
|
||||
for (int z__b_unique_name() = b_list_iterator_begin(q, it); \
|
||||
(it)->entry != NULL; b_list_iterator_next(it))
|
||||
|
||||
typedef struct b_list_iterator {
|
||||
b_queue_iterator _base;
|
||||
const b_list *_q;
|
||||
const struct b_list_p *_q_p;
|
||||
|
||||
size_t i;
|
||||
void *item;
|
||||
b_list_entry *entry;
|
||||
} b_list_iterator;
|
||||
|
||||
BLUE_API b_type b_list_get_type(void);
|
||||
BLUE_API b_type b_list_iterator_get_type(void);
|
||||
|
||||
B_TYPE_DEFAULT_CONSTRUCTOR(b_list, B_TYPE_LIST);
|
||||
|
||||
@@ -60,13 +53,11 @@ BLUE_API b_status b_list_delete_item(b_list *q, void *ptr);
|
||||
BLUE_API b_status b_list_delete_entry(b_list *q, b_list_entry *entry);
|
||||
BLUE_API void b_list_delete_all(b_list *q);
|
||||
|
||||
BLUE_API int b_list_iterator_begin(const b_list *q, b_list_iterator *it);
|
||||
BLUE_API bool b_list_iterator_next(b_list_iterator *it);
|
||||
BLUE_API b_status b_list_iterator_erase(b_list_iterator *it);
|
||||
BLUE_API bool b_list_iterator_is_valid(const b_list_iterator *it);
|
||||
|
||||
BLUE_API void *b_list_entry_value(const b_list_entry *entry);
|
||||
|
||||
BLUE_API b_iterator *b_list_begin(b_list *q);
|
||||
BLUE_API b_iterator *b_list_cbegin(const b_list *q);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user