meta: rename to fx
This commit is contained in:
378
ds/list.c
378
ds/list.c
@@ -1,102 +1,102 @@
|
||||
#include <blue/core/iterator.h>
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/ds/list.h>
|
||||
#include <fx/core/iterator.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <fx/ds/list.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*** PRIVATE DATA *************************************************************/
|
||||
|
||||
struct b_list_entry {
|
||||
struct b_queue_entry e_entry;
|
||||
struct fx_list_entry {
|
||||
struct fx_queue_entry e_entry;
|
||||
void *e_data;
|
||||
};
|
||||
|
||||
struct b_list_p {
|
||||
struct b_queue l_queue;
|
||||
struct fx_list_p {
|
||||
struct fx_queue l_queue;
|
||||
size_t l_len;
|
||||
};
|
||||
|
||||
struct b_list_iterator_p {
|
||||
b_list *_q;
|
||||
struct b_list_p *_q_p;
|
||||
struct b_queue_entry *_q_entry;
|
||||
struct fx_list_iterator_p {
|
||||
fx_list *_q;
|
||||
struct fx_list_p *_q_p;
|
||||
struct fx_queue_entry *_q_entry;
|
||||
|
||||
size_t i;
|
||||
void *item;
|
||||
b_list_entry *entry;
|
||||
fx_list_entry *entry;
|
||||
};
|
||||
|
||||
/*** PRIVATE FUNCTIONS ********************************************************/
|
||||
|
||||
static bool list_empty(struct b_list_p *q)
|
||||
static bool list_empty(struct fx_list_p *q)
|
||||
{
|
||||
return q->l_len == 0;
|
||||
}
|
||||
|
||||
static void *list_first_item(const struct b_list_p *q)
|
||||
static void *list_first_item(const struct fx_list_p *q)
|
||||
{
|
||||
struct b_queue_entry *entry = b_queue_first(&q->l_queue);
|
||||
struct fx_queue_entry *entry = fx_queue_first(&q->l_queue);
|
||||
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct b_list_entry *list_entry
|
||||
= b_unbox(struct b_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
|
||||
return list_entry->e_data;
|
||||
}
|
||||
|
||||
static void *list_last_item(const struct b_list_p *q)
|
||||
static void *list_last_item(const struct fx_list_p *q)
|
||||
{
|
||||
struct b_queue_entry *entry = b_queue_last(&q->l_queue);
|
||||
struct fx_queue_entry *entry = fx_queue_last(&q->l_queue);
|
||||
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct b_list_entry *list_entry
|
||||
= b_unbox(struct b_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
|
||||
return list_entry->e_data;
|
||||
}
|
||||
|
||||
static struct b_list_entry *list_first_entry(const struct b_list_p *q)
|
||||
static struct fx_list_entry *list_first_entry(const struct fx_list_p *q)
|
||||
{
|
||||
struct b_queue_entry *entry = b_queue_first(&q->l_queue);
|
||||
struct fx_queue_entry *entry = fx_queue_first(&q->l_queue);
|
||||
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct b_list_entry *list_entry
|
||||
= b_unbox(struct b_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
|
||||
return list_entry;
|
||||
}
|
||||
|
||||
static struct b_list_entry *list_last_entry(const struct b_list_p *q)
|
||||
static struct fx_list_entry *list_last_entry(const struct fx_list_p *q)
|
||||
{
|
||||
struct b_queue_entry *entry = b_queue_last(&q->l_queue);
|
||||
struct fx_queue_entry *entry = fx_queue_last(&q->l_queue);
|
||||
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct b_list_entry *list_entry
|
||||
= b_unbox(struct b_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
|
||||
return list_entry;
|
||||
}
|
||||
|
||||
static size_t list_length(const struct b_list_p *q)
|
||||
static size_t list_length(const struct fx_list_p *q)
|
||||
{
|
||||
return q->l_len;
|
||||
}
|
||||
|
||||
static struct b_list_entry *make_entry(void *item)
|
||||
static struct fx_list_entry *make_entry(void *item)
|
||||
{
|
||||
struct b_list_entry *entry = malloc(sizeof *entry);
|
||||
struct fx_list_entry *entry = malloc(sizeof *entry);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -108,65 +108,65 @@ static struct b_list_entry *make_entry(void *item)
|
||||
return entry;
|
||||
}
|
||||
|
||||
static struct b_list_entry *list_insert_before(
|
||||
struct b_list_p *q, void *ptr, struct b_list_entry *before)
|
||||
static struct fx_list_entry *list_insert_before(
|
||||
struct fx_list_p *q, void *ptr, struct fx_list_entry *before)
|
||||
{
|
||||
struct b_list_entry *entry = make_entry(ptr);
|
||||
struct fx_list_entry *entry = make_entry(ptr);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_insert_before(&q->l_queue, &entry->e_entry, &before->e_entry);
|
||||
fx_queue_insert_before(&q->l_queue, &entry->e_entry, &before->e_entry);
|
||||
q->l_len++;
|
||||
return entry;
|
||||
}
|
||||
|
||||
static struct b_list_entry *list_insert_after(
|
||||
struct b_list_p *q, void *ptr, struct b_list_entry *after)
|
||||
static struct fx_list_entry *list_insert_after(
|
||||
struct fx_list_p *q, void *ptr, struct fx_list_entry *after)
|
||||
{
|
||||
struct b_list_entry *entry = make_entry(ptr);
|
||||
struct fx_list_entry *entry = make_entry(ptr);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_insert_after(&q->l_queue, &entry->e_entry, &after->e_entry);
|
||||
fx_queue_insert_after(&q->l_queue, &entry->e_entry, &after->e_entry);
|
||||
q->l_len++;
|
||||
return entry;
|
||||
}
|
||||
|
||||
static struct b_list_entry *list_push_front(struct b_list_p *q, void *ptr)
|
||||
static struct fx_list_entry *list_push_front(struct fx_list_p *q, void *ptr)
|
||||
{
|
||||
struct b_list_entry *entry = make_entry(ptr);
|
||||
struct fx_list_entry *entry = make_entry(ptr);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_push_front(&q->l_queue, &entry->e_entry);
|
||||
fx_queue_push_front(&q->l_queue, &entry->e_entry);
|
||||
q->l_len++;
|
||||
return entry;
|
||||
}
|
||||
|
||||
static struct b_list_entry *list_push_back(struct b_list_p *q, void *ptr)
|
||||
static struct fx_list_entry *list_push_back(struct fx_list_p *q, void *ptr)
|
||||
{
|
||||
struct b_list_entry *entry = make_entry(ptr);
|
||||
struct fx_list_entry *entry = make_entry(ptr);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_push_back(&q->l_queue, &entry->e_entry);
|
||||
fx_queue_push_back(&q->l_queue, &entry->e_entry);
|
||||
q->l_len++;
|
||||
return entry;
|
||||
}
|
||||
|
||||
static void *list_pop_front(struct b_list_p *q)
|
||||
static void *list_pop_front(struct fx_list_p *q)
|
||||
{
|
||||
struct b_queue_entry *entry = b_queue_pop_front(&q->l_queue);
|
||||
struct fx_queue_entry *entry = fx_queue_pop_front(&q->l_queue);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct b_list_entry *list_entry
|
||||
= b_unbox(struct b_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
|
||||
void *item = list_entry->e_data;
|
||||
free(list_entry);
|
||||
@@ -176,15 +176,15 @@ static void *list_pop_front(struct b_list_p *q)
|
||||
return item;
|
||||
}
|
||||
|
||||
static void *list_pop_back(struct b_list_p *q)
|
||||
static void *list_pop_back(struct fx_list_p *q)
|
||||
{
|
||||
struct b_queue_entry *entry = b_queue_pop_back(&q->l_queue);
|
||||
struct fx_queue_entry *entry = fx_queue_pop_back(&q->l_queue);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct b_list_entry *list_entry
|
||||
= b_unbox(struct b_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
|
||||
void *item = list_entry->e_data;
|
||||
free(list_entry);
|
||||
@@ -194,55 +194,55 @@ static void *list_pop_back(struct b_list_p *q)
|
||||
return item;
|
||||
}
|
||||
|
||||
static struct b_list_entry *find_item(struct b_list_p *list, void *item)
|
||||
static struct fx_list_entry *find_item(struct fx_list_p *list, void *item)
|
||||
{
|
||||
struct b_queue_entry *entry = b_queue_first(&list->l_queue);
|
||||
struct fx_queue_entry *entry = fx_queue_first(&list->l_queue);
|
||||
while (entry) {
|
||||
struct b_list_entry *list_entry
|
||||
= b_unbox(struct b_list_entry, entry, e_entry);
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
|
||||
if (list_entry->e_data == item) {
|
||||
return list_entry;
|
||||
}
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static b_status list_delete_item(struct b_list_p *q, void *ptr)
|
||||
static fx_status list_delete_item(struct fx_list_p *q, void *ptr)
|
||||
{
|
||||
struct b_list_entry *entry = find_item(q, ptr);
|
||||
struct fx_list_entry *entry = find_item(q, ptr);
|
||||
if (!entry) {
|
||||
return B_ERR_NO_ENTRY;
|
||||
return FX_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
b_queue_delete(&q->l_queue, &entry->e_entry);
|
||||
fx_queue_delete(&q->l_queue, &entry->e_entry);
|
||||
q->l_len--;
|
||||
|
||||
free(entry);
|
||||
|
||||
return B_SUCCESS;
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static b_status list_delete_entry(struct b_list_p *q, struct b_list_entry *entry)
|
||||
static fx_status list_delete_entry(struct fx_list_p *q, struct fx_list_entry *entry)
|
||||
{
|
||||
b_queue_delete(&q->l_queue, &entry->e_entry);
|
||||
fx_queue_delete(&q->l_queue, &entry->e_entry);
|
||||
q->l_len--;
|
||||
|
||||
free(entry);
|
||||
|
||||
return B_SUCCESS;
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static void list_delete_all(struct b_list_p *q)
|
||||
static void list_delete_all(struct fx_list_p *q)
|
||||
{
|
||||
struct b_queue_entry *entry = b_queue_first(&q->l_queue);
|
||||
struct fx_queue_entry *entry = fx_queue_first(&q->l_queue);
|
||||
while (entry) {
|
||||
struct b_list_entry *list_entry
|
||||
= b_unbox(struct b_list_entry, entry, e_entry);
|
||||
struct b_queue_entry *next = b_queue_next(entry);
|
||||
struct fx_list_entry *list_entry
|
||||
= fx_unbox(struct fx_list_entry, entry, e_entry);
|
||||
struct fx_queue_entry *next = fx_queue_next(entry);
|
||||
|
||||
free(list_entry);
|
||||
entry = next;
|
||||
@@ -253,130 +253,130 @@ static void list_delete_all(struct b_list_p *q)
|
||||
|
||||
/*** PUBLIC FUNCTIONS *********************************************************/
|
||||
|
||||
bool b_list_empty(b_list *q)
|
||||
bool fx_list_empty(fx_list *q)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC_0(B_TYPE_LIST, list_empty, q);
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_LIST, list_empty, q);
|
||||
}
|
||||
|
||||
void *b_list_first_item(const b_list *q)
|
||||
void *fx_list_first_item(const fx_list *q)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC_0(B_TYPE_LIST, list_first_item, q);
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_LIST, list_first_item, q);
|
||||
}
|
||||
|
||||
void *b_list_last_item(const b_list *q)
|
||||
void *fx_list_last_item(const fx_list *q)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC_0(B_TYPE_LIST, list_last_item, q);
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_LIST, list_last_item, q);
|
||||
}
|
||||
|
||||
struct b_list_entry *b_list_first_entry(const b_list *q)
|
||||
struct fx_list_entry *fx_list_first_entry(const fx_list *q)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC_0(B_TYPE_LIST, list_first_entry, q);
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_LIST, list_first_entry, q);
|
||||
}
|
||||
|
||||
struct b_list_entry *b_list_last_entry(const b_list *q)
|
||||
struct fx_list_entry *fx_list_last_entry(const fx_list *q)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC_0(B_TYPE_LIST, b_list_last_entry, q);
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_LIST, fx_list_last_entry, q);
|
||||
}
|
||||
|
||||
struct b_list_entry *b_list_next(const struct b_list_entry *entry)
|
||||
struct fx_list_entry *fx_list_next(const struct fx_list_entry *entry)
|
||||
{
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct b_queue_entry *next = b_queue_next(&entry->e_entry);
|
||||
struct fx_queue_entry *next = fx_queue_next(&entry->e_entry);
|
||||
|
||||
if (!next) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct b_list_entry, next, e_entry);
|
||||
return fx_unbox(struct fx_list_entry, next, e_entry);
|
||||
}
|
||||
|
||||
struct b_list_entry *b_list_prev(const struct b_list_entry *entry)
|
||||
struct fx_list_entry *fx_list_prev(const struct fx_list_entry *entry)
|
||||
{
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct b_queue_entry *next = b_queue_prev(&entry->e_entry);
|
||||
struct fx_queue_entry *next = fx_queue_prev(&entry->e_entry);
|
||||
|
||||
if (!next) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct b_list_entry, next, e_entry);
|
||||
return fx_unbox(struct fx_list_entry, next, e_entry);
|
||||
}
|
||||
|
||||
size_t b_list_length(const b_list *q)
|
||||
size_t fx_list_length(const fx_list *q)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC_0(B_TYPE_LIST, list_length, q);
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_LIST, list_length, q);
|
||||
}
|
||||
|
||||
struct b_list_entry *b_list_insert_before(
|
||||
b_list *q, void *ptr, struct b_list_entry *before)
|
||||
struct fx_list_entry *fx_list_insert_before(
|
||||
fx_list *q, void *ptr, struct fx_list_entry *before)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC(B_TYPE_LIST, list_insert_before, q, ptr, before);
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_LIST, list_insert_before, q, ptr, before);
|
||||
}
|
||||
|
||||
struct b_list_entry *b_list_insert_after(
|
||||
b_list *q, void *ptr, struct b_list_entry *after)
|
||||
struct fx_list_entry *fx_list_insert_after(
|
||||
fx_list *q, void *ptr, struct fx_list_entry *after)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC(B_TYPE_LIST, list_insert_after, q, ptr, after);
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_LIST, list_insert_after, q, ptr, after);
|
||||
}
|
||||
|
||||
struct b_list_entry *b_list_push_front(b_list *q, void *ptr)
|
||||
struct fx_list_entry *fx_list_push_front(fx_list *q, void *ptr)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC(B_TYPE_LIST, list_push_front, q, ptr);
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_LIST, list_push_front, q, ptr);
|
||||
}
|
||||
|
||||
struct b_list_entry *b_list_push_back(b_list *q, void *ptr)
|
||||
struct fx_list_entry *fx_list_push_back(fx_list *q, void *ptr)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC(B_TYPE_LIST, list_push_back, q, ptr);
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_LIST, list_push_back, q, ptr);
|
||||
}
|
||||
|
||||
void *b_list_pop_front(b_list *q)
|
||||
void *fx_list_pop_front(fx_list *q)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC_0(B_TYPE_LIST, list_pop_front, q);
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_LIST, list_pop_front, q);
|
||||
}
|
||||
|
||||
void *b_list_pop_back(b_list *q)
|
||||
void *fx_list_pop_back(fx_list *q)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC_0(B_TYPE_LIST, list_pop_back, q);
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_LIST, list_pop_back, q);
|
||||
}
|
||||
|
||||
b_status b_list_delete_item(b_list *q, void *ptr)
|
||||
fx_status fx_list_delete_item(fx_list *q, void *ptr)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC(B_TYPE_LIST, list_delete_item, q, ptr);
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_LIST, list_delete_item, q, ptr);
|
||||
}
|
||||
|
||||
b_status b_list_delete_entry(b_list *q, struct b_list_entry *entry)
|
||||
fx_status fx_list_delete_entry(fx_list *q, struct fx_list_entry *entry)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC(B_TYPE_LIST, list_delete_entry, q, entry);
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_LIST, list_delete_entry, q, entry);
|
||||
}
|
||||
|
||||
void b_list_delete_all(b_list *q)
|
||||
void fx_list_delete_all(fx_list *q)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC_0(B_TYPE_LIST, list_delete_all, q);
|
||||
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_LIST, list_delete_all, q);
|
||||
}
|
||||
|
||||
void *b_list_entry_value(const struct b_list_entry *entry)
|
||||
void *fx_list_entry_value(const struct fx_list_entry *entry)
|
||||
{
|
||||
return entry ? entry->e_data : NULL;
|
||||
}
|
||||
|
||||
b_iterator *b_list_begin(b_list *q)
|
||||
fx_iterator *fx_list_begin(fx_list *q)
|
||||
{
|
||||
b_list_iterator *it_obj = b_object_create(B_TYPE_LIST_ITERATOR);
|
||||
struct b_list_iterator_p *it
|
||||
= b_object_get_private(it_obj, B_TYPE_LIST_ITERATOR);
|
||||
fx_list_iterator *it_obj = fx_object_create(FX_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(it_obj, FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
it->_q = q;
|
||||
it->_q_p = b_object_get_private(q, B_TYPE_LIST);
|
||||
it->_q_entry = b_queue_first(&it->_q_p->l_queue);
|
||||
it->_q_p = fx_object_get_private(q, FX_TYPE_LIST);
|
||||
it->_q_entry = fx_queue_first(&it->_q_p->l_queue);
|
||||
|
||||
it->i = 0;
|
||||
it->entry = b_unbox(struct b_list_entry, it->_q_entry, e_entry);
|
||||
it->entry = fx_unbox(struct fx_list_entry, it->_q_entry, e_entry);
|
||||
if (it->entry) {
|
||||
it->item = it->entry->e_data;
|
||||
}
|
||||
@@ -384,18 +384,18 @@ b_iterator *b_list_begin(b_list *q)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const b_iterator *b_list_cbegin(const b_list *q)
|
||||
const fx_iterator *fx_list_cbegin(const fx_list *q)
|
||||
{
|
||||
b_list_iterator *it_obj = b_object_create(B_TYPE_LIST_ITERATOR);
|
||||
struct b_list_iterator_p *it
|
||||
= b_object_get_private(it_obj, B_TYPE_LIST_ITERATOR);
|
||||
fx_list_iterator *it_obj = fx_object_create(FX_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(it_obj, FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
it->_q = (b_list *)q;
|
||||
it->_q_p = b_object_get_private(q, B_TYPE_LIST);
|
||||
it->_q_entry = b_queue_first(&it->_q_p->l_queue);
|
||||
it->_q = (fx_list *)q;
|
||||
it->_q_p = fx_object_get_private(q, FX_TYPE_LIST);
|
||||
it->_q_entry = fx_queue_first(&it->_q_p->l_queue);
|
||||
|
||||
it->i = 0;
|
||||
it->entry = b_unbox(struct b_list_entry, it->_q_entry, e_entry);
|
||||
it->entry = fx_unbox(struct fx_list_entry, it->_q_entry, e_entry);
|
||||
if (it->entry) {
|
||||
it->item = it->entry->e_data;
|
||||
}
|
||||
@@ -405,39 +405,39 @@ const b_iterator *b_list_cbegin(const b_list *q)
|
||||
|
||||
/*** VIRTUAL FUNCTIONS ********************************************************/
|
||||
|
||||
static void list_init(b_object *obj, void *priv)
|
||||
static void list_init(fx_object *obj, void *priv)
|
||||
{
|
||||
struct b_list_p *list = priv;
|
||||
struct fx_list_p *list = priv;
|
||||
}
|
||||
|
||||
static void list_fini(b_object *obj, void *priv)
|
||||
static void list_fini(fx_object *obj, void *priv)
|
||||
{
|
||||
struct b_list_p *list = priv;
|
||||
struct fx_list_p *list = priv;
|
||||
list_delete_all(list);
|
||||
}
|
||||
|
||||
/*** ITERATOR FUNCTIONS *******************************************************/
|
||||
|
||||
static enum b_status iterator_move_next(const b_iterator *obj)
|
||||
static enum fx_status iterator_move_next(const fx_iterator *obj)
|
||||
{
|
||||
struct b_list_iterator_p *it
|
||||
= b_object_get_private(obj, B_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(obj, FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
if (!it->_q_entry) {
|
||||
it->entry = NULL;
|
||||
it->item = NULL;
|
||||
return B_ERR_NO_DATA;
|
||||
return FX_ERR_NO_DATA;
|
||||
}
|
||||
|
||||
it->_q_entry = b_queue_next(it->_q_entry);
|
||||
it->_q_entry = fx_queue_next(it->_q_entry);
|
||||
if (!it->_q_entry) {
|
||||
it->entry = NULL;
|
||||
it->item = NULL;
|
||||
return B_ERR_NO_DATA;
|
||||
return FX_ERR_NO_DATA;
|
||||
}
|
||||
|
||||
it->i++;
|
||||
it->entry = b_unbox(struct b_list_entry, it->_q_entry, e_entry);
|
||||
it->entry = fx_unbox(struct fx_list_entry, it->_q_entry, e_entry);
|
||||
if (it->entry) {
|
||||
it->item = it->entry->e_data;
|
||||
}
|
||||
@@ -445,85 +445,85 @@ static enum b_status iterator_move_next(const b_iterator *obj)
|
||||
return it->entry != NULL;
|
||||
}
|
||||
|
||||
static enum b_status iterator_erase(b_iterator *obj)
|
||||
static enum fx_status iterator_erase(fx_iterator *obj)
|
||||
{
|
||||
struct b_list_iterator_p *it
|
||||
= b_object_get_private(obj, B_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(obj, FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
if (!it->entry || !it->_q_entry) {
|
||||
return B_ERR_OUT_OF_BOUNDS;
|
||||
return FX_ERR_OUT_OF_BOUNDS;
|
||||
}
|
||||
|
||||
struct b_queue_entry *next = b_queue_next(it->_q_entry);
|
||||
struct fx_queue_entry *next = fx_queue_next(it->_q_entry);
|
||||
|
||||
b_queue_delete(&it->_q_p->l_queue, it->_q_entry);
|
||||
fx_queue_delete(&it->_q_p->l_queue, it->_q_entry);
|
||||
free(it->entry);
|
||||
|
||||
it->_q_entry = next;
|
||||
it->entry = b_unbox(struct b_list_entry, it->_q_entry, e_entry);
|
||||
it->entry = fx_unbox(struct fx_list_entry, it->_q_entry, e_entry);
|
||||
if (it->entry) {
|
||||
it->item = it->entry->e_data;
|
||||
}
|
||||
|
||||
return B_SUCCESS;
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static b_iterator_value iterator_get_value(b_iterator *obj)
|
||||
static fx_iterator_value iterator_get_value(fx_iterator *obj)
|
||||
{
|
||||
struct b_list_iterator_p *it
|
||||
= b_object_get_private(obj, B_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(obj, FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
return B_ITERATOR_VALUE_PTR(it->item);
|
||||
return FX_ITERATOR_VALUE_PTR(it->item);
|
||||
}
|
||||
|
||||
static const b_iterator_value iterator_get_cvalue(const b_iterator *obj)
|
||||
static const fx_iterator_value iterator_get_cvalue(const fx_iterator *obj)
|
||||
{
|
||||
struct b_list_iterator_p *it
|
||||
= b_object_get_private(obj, B_TYPE_LIST_ITERATOR);
|
||||
struct fx_list_iterator_p *it
|
||||
= fx_object_get_private(obj, FX_TYPE_LIST_ITERATOR);
|
||||
|
||||
return B_ITERATOR_VALUE_CPTR(it->item);
|
||||
return FX_ITERATOR_VALUE_CPTR(it->item);
|
||||
}
|
||||
|
||||
/*** CLASS DEFINITION *********************************************************/
|
||||
|
||||
// ---- b_list DEFINITION
|
||||
B_TYPE_CLASS_DEFINITION_BEGIN(b_list)
|
||||
B_TYPE_CLASS_INTERFACE_BEGIN(b_object, B_TYPE_OBJECT)
|
||||
B_INTERFACE_ENTRY(to_string) = NULL;
|
||||
B_TYPE_CLASS_INTERFACE_END(b_object, B_TYPE_OBJECT)
|
||||
// ---- fx_list DEFINITION
|
||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_list)
|
||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||
|
||||
B_TYPE_CLASS_INTERFACE_BEGIN(b_iterable, B_TYPE_ITERABLE)
|
||||
B_INTERFACE_ENTRY(it_begin) = b_list_begin;
|
||||
B_INTERFACE_ENTRY(it_cbegin) = b_list_cbegin;
|
||||
B_TYPE_CLASS_INTERFACE_END(b_iterable, B_TYPE_ITERABLE)
|
||||
B_TYPE_CLASS_DEFINITION_END(b_list)
|
||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterable, FX_TYPE_ITERABLE)
|
||||
FX_INTERFACE_ENTRY(it_begin) = fx_list_begin;
|
||||
FX_INTERFACE_ENTRY(it_cbegin) = fx_list_cbegin;
|
||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterable, FX_TYPE_ITERABLE)
|
||||
FX_TYPE_CLASS_DEFINITION_END(fx_list)
|
||||
|
||||
B_TYPE_DEFINITION_BEGIN(b_list)
|
||||
B_TYPE_ID(0x8730e66f, 0x0fd9, 0x4773, 0x9bbd, 0x6428f6e495eb);
|
||||
B_TYPE_CLASS(b_list_class);
|
||||
B_TYPE_IMPLEMENTS(B_TYPE_ITERABLE);
|
||||
B_TYPE_INSTANCE_PRIVATE(struct b_list_p);
|
||||
B_TYPE_INSTANCE_INIT(list_init);
|
||||
B_TYPE_INSTANCE_FINI(list_fini);
|
||||
B_TYPE_DEFINITION_END(b_list)
|
||||
FX_TYPE_DEFINITION_BEGIN(fx_list)
|
||||
FX_TYPE_ID(0x8730e66f, 0x0fd9, 0x4773, 0x9bbd, 0x6428f6e495eb);
|
||||
FX_TYPE_CLASS(fx_list_class);
|
||||
FX_TYPE_IMPLEMENTS(FX_TYPE_ITERABLE);
|
||||
FX_TYPE_INSTANCE_PRIVATE(struct fx_list_p);
|
||||
FX_TYPE_INSTANCE_INIT(list_init);
|
||||
FX_TYPE_INSTANCE_FINI(list_fini);
|
||||
FX_TYPE_DEFINITION_END(fx_list)
|
||||
|
||||
// ---- b_list_iterator DEFINITION
|
||||
B_TYPE_CLASS_DEFINITION_BEGIN(b_list_iterator)
|
||||
B_TYPE_CLASS_INTERFACE_BEGIN(b_object, B_TYPE_OBJECT)
|
||||
B_INTERFACE_ENTRY(to_string) = NULL;
|
||||
B_TYPE_CLASS_INTERFACE_END(b_object, B_TYPE_OBJECT)
|
||||
// ---- fx_list_iterator DEFINITION
|
||||
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_list_iterator)
|
||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
|
||||
FX_INTERFACE_ENTRY(to_string) = NULL;
|
||||
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
|
||||
|
||||
B_TYPE_CLASS_INTERFACE_BEGIN(b_iterator, B_TYPE_ITERATOR)
|
||||
B_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
||||
B_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
||||
B_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
||||
B_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
||||
B_TYPE_CLASS_INTERFACE_END(b_iterator, B_TYPE_ITERATOR)
|
||||
B_TYPE_CLASS_DEFINITION_END(b_list_iterator)
|
||||
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_iterator, FX_TYPE_ITERATOR)
|
||||
FX_INTERFACE_ENTRY(it_move_next) = iterator_move_next;
|
||||
FX_INTERFACE_ENTRY(it_erase) = iterator_erase;
|
||||
FX_INTERFACE_ENTRY(it_get_value) = iterator_get_value;
|
||||
FX_INTERFACE_ENTRY(it_get_cvalue) = iterator_get_cvalue;
|
||||
FX_TYPE_CLASS_INTERFACE_END(fx_iterator, FX_TYPE_ITERATOR)
|
||||
FX_TYPE_CLASS_DEFINITION_END(fx_list_iterator)
|
||||
|
||||
B_TYPE_DEFINITION_BEGIN(b_list_iterator)
|
||||
B_TYPE_ID(0xd9658456, 0xdd80, 0x419a, 0xb23a, 0xb513013e6431);
|
||||
B_TYPE_EXTENDS(B_TYPE_ITERATOR);
|
||||
B_TYPE_CLASS(b_list_iterator_class);
|
||||
B_TYPE_INSTANCE_PRIVATE(struct b_list_iterator_p);
|
||||
B_TYPE_DEFINITION_END(b_list_iterator)
|
||||
FX_TYPE_DEFINITION_BEGIN(fx_list_iterator)
|
||||
FX_TYPE_ID(0xd9658456, 0xdd80, 0x419a, 0xb23a, 0xb513013e6431);
|
||||
FX_TYPE_EXTENDS(FX_TYPE_ITERATOR);
|
||||
FX_TYPE_CLASS(fx_list_iterator_class);
|
||||
FX_TYPE_INSTANCE_PRIVATE(struct fx_list_iterator_p);
|
||||
FX_TYPE_DEFINITION_END(fx_list_iterator)
|
||||
|
||||
Reference in New Issue
Block a user