linked list rename mod to ex
This commit is contained in:
143
src/core/core.h
143
src/core/core.h
@@ -124,47 +124,47 @@ typedef double f64;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Single linked list Queue
|
// Single linked list Queue
|
||||||
#define SLLQ_APPEND_MOD(f, l, n, next) \
|
#define SLLQ_APPEND_EX(f, l, n, next) \
|
||||||
|
do { \
|
||||||
|
assert((n)->next == NULL); \
|
||||||
|
if ((f) == 0) { \
|
||||||
|
(f) = (l) = (n); \
|
||||||
|
} else { \
|
||||||
|
(l) = (l)->next = (n); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#define SLLQ_APPEND(f, l, n) SLLQ_APPEND_EX(f, l, n, next)
|
||||||
|
|
||||||
|
#define SLLQ_PREPEND_EX(f, l, n, next) \
|
||||||
do { \
|
do { \
|
||||||
assert((n)->next == NULL); \
|
assert((n)->next == NULL); \
|
||||||
if ((f) == 0) { \
|
if ((f) == 0) { \
|
||||||
(f) = (l) = (n); \
|
(f) = (l) = (n); \
|
||||||
} else { \
|
} else { \
|
||||||
(l) = (l)->next = (n); \
|
(n)->next = (f); \
|
||||||
|
(f) = (n); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define SLLQ_APPEND(f, l, n) SLLQ_APPEND_MOD(f, l, n, next)
|
#define SLLQ_PREPEND(f, l, n) SLLQ_PREPEND_EX(f, l, n, next)
|
||||||
|
|
||||||
#define SLLQ_PREPEND_MOD(f, l, n, next) \
|
#define SLLQ_REMOVE_FIRST_EX(f, l, next) \
|
||||||
do { \
|
do { \
|
||||||
assert((n)->next == NULL); \
|
if ((f) == (l)) { \
|
||||||
if ((f) == 0) { \
|
(f) = (l) = 0; \
|
||||||
(f) = (l) = (n); \
|
} else { \
|
||||||
} else { \
|
(f) = (f)->next; \
|
||||||
(n)->next = (f); \
|
} \
|
||||||
(f) = (n); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
#define SLLQ_PREPEND(f, l, n) SLLQ_PREPEND_MOD(f, l, n, next)
|
#define SLLQ_REMOVE_FIRST(f, l) SLLQ_REMOVE_FIRST_EX(f, l, next)
|
||||||
|
|
||||||
#define SLLQ_REMOVE_FIRST_MOD(f, l, next) \
|
|
||||||
do { \
|
|
||||||
if ((f) == (l)) { \
|
|
||||||
(f) = (l) = 0; \
|
|
||||||
} else { \
|
|
||||||
(f) = (f)->next; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
#define SLLQ_REMOVE_FIRST(f, l) SLLQ_REMOVE_FIRST_MOD(f, l, next)
|
|
||||||
|
|
||||||
// Singly linked list stack
|
// Singly linked list stack
|
||||||
#define SLLS_PUSH_MOD(stack_base, new_stack_base, next) \
|
#define SLLS_PUSH_EX(stack_base, new_stack_base, next) \
|
||||||
do { \
|
do { \
|
||||||
(new_stack_base)->next = (stack_base); \
|
(new_stack_base)->next = (stack_base); \
|
||||||
(stack_base) = (new_stack_base); \
|
(stack_base) = (new_stack_base); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define SLLS_PUSH(stack_base, new_stack_base) \
|
#define SLLS_PUSH(stack_base, new_stack_base) \
|
||||||
SLLS_PUSH_MOD(stack_base, new_stack_base, next)
|
SLLS_PUSH_EX(stack_base, new_stack_base, next)
|
||||||
|
|
||||||
#define SLLS_POP_AND_STORE(stack_base, out_node) \
|
#define SLLS_POP_AND_STORE(stack_base, out_node) \
|
||||||
do { \
|
do { \
|
||||||
@@ -176,60 +176,60 @@ typedef double f64;
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
// Doubly linked list Queue
|
// Doubly linked list Queue
|
||||||
#define DLLQ_APPEND_MOD(f, l, node, next, prev) \
|
#define DLLQ_APPEND_EX(f, l, node, next, prev) \
|
||||||
|
do { \
|
||||||
|
assert((node)->next == NULL); \
|
||||||
|
assert((node)->prev == NULL); \
|
||||||
|
if ((f) == 0) { \
|
||||||
|
(f) = (l) = (node); \
|
||||||
|
} else { \
|
||||||
|
(l)->next = (node); \
|
||||||
|
(node)->prev = (l); \
|
||||||
|
(l) = (node); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#define DLLQ_APPEND(f, l, node) DLLQ_APPEND_EX(f, l, node, next, prev)
|
||||||
|
|
||||||
|
#define DLLQ_PREPEND_EX(f, l, node, next, prev) \
|
||||||
do { \
|
do { \
|
||||||
assert((node)->next == NULL); \
|
assert((node)->next == NULL); \
|
||||||
assert((node)->prev == NULL); \
|
assert((node)->prev == NULL); \
|
||||||
if ((f) == 0) { \
|
if ((f) == 0) { \
|
||||||
(f) = (l) = (node); \
|
(f) = (l) = (node); \
|
||||||
} else { \
|
} else { \
|
||||||
(l)->next = (node); \
|
(node)->next = (f); \
|
||||||
(node)->prev = (l); \
|
(f)->prev = (node); \
|
||||||
(l) = (node); \
|
(f) = (node); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define DLLQ_APPEND(f, l, node) DLLQ_APPEND_MOD(f, l, node, next, prev)
|
#define DLLQ_PREPEND(f, l, node) DLLQ_PREPEND_EX(f, l, node, next, prev)
|
||||||
|
|
||||||
#define DLLQ_PREPEND_MOD(f, l, node, next, prev) \
|
|
||||||
do { \
|
|
||||||
assert((node)->next == NULL); \
|
|
||||||
assert((node)->prev == NULL); \
|
|
||||||
if ((f) == 0) { \
|
|
||||||
(f) = (l) = (node); \
|
|
||||||
} else { \
|
|
||||||
(node)->next = (f); \
|
|
||||||
(f)->prev = (node); \
|
|
||||||
(f) = (node); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
#define DLLQ_PREPEND(f, l, node) DLLQ_PREPEND_MOD(f, l, node, next, prev)
|
|
||||||
|
|
||||||
#define DLLQ_CONTAINS(f, l, n, next, prev) for (
|
#define DLLQ_CONTAINS(f, l, n, next, prev) for (
|
||||||
|
|
||||||
#define DLLQ_REMOVE_MOD(first, last, node, next, prev) \
|
#define DLLQ_REMOVE_EX(first, last, node, next, prev) \
|
||||||
do { \
|
do { \
|
||||||
if ((first) == (last)) { \
|
if ((first) == (last)) { \
|
||||||
assert((node) == (first)); \
|
assert((node) == (first)); \
|
||||||
(first) = (last) = 0; \
|
(first) = (last) = 0; \
|
||||||
} else if ((last) == (node)) { \
|
} else if ((last) == (node)) { \
|
||||||
(last) = (last)->prev; \
|
(last) = (last)->prev; \
|
||||||
(last)->next = 0; \
|
(last)->next = 0; \
|
||||||
} else if ((first) == (node)) { \
|
} else if ((first) == (node)) { \
|
||||||
(first) = (first)->next; \
|
(first) = (first)->next; \
|
||||||
(first)->prev = 0; \
|
(first)->prev = 0; \
|
||||||
} else { \
|
} else { \
|
||||||
(node)->prev->next = (node)->next; \
|
(node)->prev->next = (node)->next; \
|
||||||
(node)->next->prev = (node)->prev; \
|
(node)->next->prev = (node)->prev; \
|
||||||
} \
|
} \
|
||||||
if (node) { \
|
if (node) { \
|
||||||
(node)->prev = 0; \
|
(node)->prev = 0; \
|
||||||
(node)->next = 0; \
|
(node)->next = 0; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define DLLQ_REMOVE(first, last, node) DLLQ_REMOVE_MOD(first, last, node, next, prev)
|
#define DLLQ_REMOVE(first, last, node) DLLQ_REMOVE_EX(first, last, node, next, prev)
|
||||||
|
|
||||||
// Doubly linked list Stack
|
// Doubly linked list Stack
|
||||||
#define DLLS_ADD_MOD(first, node, next, prev) \
|
#define DLLS_PUSH_EX(first, node, next, prev) \
|
||||||
do { \
|
do { \
|
||||||
assert((node)->next == NULL); \
|
assert((node)->next == NULL); \
|
||||||
assert((node)->prev == NULL); \
|
assert((node)->prev == NULL); \
|
||||||
@@ -238,8 +238,8 @@ typedef double f64;
|
|||||||
(first)->prev = (node); \
|
(first)->prev = (node); \
|
||||||
(first) = (node); \
|
(first) = (node); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define DLLS_ADD(first, node) DLLS_ADD_MOD(first, node, next, prev)
|
#define DLLS_PUSH(first, node) DLLS_PUSH_EX(first, node, next, prev)
|
||||||
#define DLLS_REMOVE_MOD(first, node, next, prev) \
|
#define DLLS_REMOVE_EX(first, node, next, prev) \
|
||||||
do { \
|
do { \
|
||||||
if ((node) == (first)) { \
|
if ((node) == (first)) { \
|
||||||
(first) = (first)->next; \
|
(first) = (first)->next; \
|
||||||
@@ -255,5 +255,4 @@ typedef double f64;
|
|||||||
(node)->next = 0; \
|
(node)->next = 0; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define DLLS_REMOVE(first, node) DLLS_REMOVE_MOD(first, node, next, prev)
|
#define DLLS_REMOVE(first, node) DLLS_REMOVE_EX(first, node, next, prev)
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ struct ui_box_t {
|
|||||||
r2f32_t rect;
|
r2f32_t rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
// @todo:
|
|
||||||
typedef struct ui_signal ui_signal;
|
typedef struct ui_signal ui_signal;
|
||||||
struct ui_signal {
|
struct ui_signal {
|
||||||
b8 clicked;
|
b8 clicked;
|
||||||
@@ -106,7 +105,7 @@ ui_box_t *ui_build_box(ui_id_t id) {
|
|||||||
memory_zero(box, offsetof(ui_box_t, id));
|
memory_zero(box, offsetof(ui_box_t, id));
|
||||||
} else {
|
} else {
|
||||||
box = ui_alloc_box();
|
box = ui_alloc_box();
|
||||||
DLLQ_APPEND_MOD(ui->first_hash, ui->last_hash, box, hash_next, hash_prev);
|
DLLQ_APPEND_EX(ui->first_hash, ui->last_hash, box, hash_next, hash_prev);
|
||||||
}
|
}
|
||||||
box->last_frame_touched_index = ui->frame->frame;
|
box->last_frame_touched_index = ui->frame->frame;
|
||||||
box->id = id;
|
box->id = id;
|
||||||
@@ -293,7 +292,7 @@ void ui_end_frame(void) {
|
|||||||
b32 touched_this_frame = ui->frame->frame <= box->last_frame_touched_index;
|
b32 touched_this_frame = ui->frame->frame <= box->last_frame_touched_index;
|
||||||
b32 is_null = box->id.value == 0;
|
b32 is_null = box->id.value == 0;
|
||||||
if (!touched_this_frame || is_null) {
|
if (!touched_this_frame || is_null) {
|
||||||
DLLQ_REMOVE_MOD(ui->first_hash, ui->last_hash, box, hash_next, hash_prev);
|
DLLQ_REMOVE_EX(ui->first_hash, ui->last_hash, box, hash_next, hash_prev);
|
||||||
zero_struct(box);
|
zero_struct(box);
|
||||||
SLLS_PUSH(ui->first_free, box);
|
SLLS_PUSH(ui->first_free, box);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user