73 lines
2.1 KiB
C
73 lines
2.1 KiB
C
#ifndef BLUE_DS_LIST_H_
|
|
#define BLUE_DS_LIST_H_
|
|
|
|
#include <blue/core/macros.h>
|
|
#include <blue/core/status.h>
|
|
|
|
B_DECLS_BEGIN;
|
|
|
|
#define B_TYPE_LIST (b_list_get_type())
|
|
|
|
struct b_list_p;
|
|
|
|
B_DECLARE_TYPE(b_list);
|
|
|
|
B_TYPE_CLASS_DECLARATION_BEGIN(b_list)
|
|
B_TYPE_CLASS_DECLARATION_END(b_list)
|
|
|
|
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);
|
|
|
|
B_TYPE_DEFAULT_CONSTRUCTOR(b_list, B_TYPE_LIST);
|
|
|
|
BLUE_API bool b_list_empty(b_list *q);
|
|
BLUE_API void *b_list_first_item(const b_list *q);
|
|
BLUE_API void *b_list_last_item(const b_list *q);
|
|
BLUE_API b_list_entry *b_list_first_entry(const b_list *q);
|
|
BLUE_API b_list_entry *b_list_last_entry(const b_list *q);
|
|
BLUE_API b_list_entry *b_list_next(const b_list_entry *entry);
|
|
BLUE_API b_list_entry *b_list_prev(const b_list_entry *entry);
|
|
|
|
BLUE_API size_t b_list_length(const b_list *q);
|
|
|
|
BLUE_API b_list_entry *b_list_insert_before(
|
|
b_list *q, void *ptr, b_list_entry *before);
|
|
BLUE_API b_list_entry *b_list_insert_after(
|
|
b_list *q, void *ptr, b_list_entry *after);
|
|
|
|
BLUE_API b_list_entry *b_list_push_front(b_list *q, void *ptr);
|
|
BLUE_API b_list_entry *b_list_push_back(b_list *q, void *ptr);
|
|
|
|
BLUE_API void *b_list_pop_front(b_list *q);
|
|
BLUE_API void *b_list_pop_back(b_list *q);
|
|
|
|
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);
|
|
|
|
B_DECLS_END;
|
|
|
|
#endif
|