39 lines
978 B
C
39 lines
978 B
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct rt_list;
|
|
|
|
void rt_list_remove(struct rt_list *node);
|
|
|
|
bool rt_list_is_empty(const struct rt_list *list);
|
|
|
|
struct rt_list *rt_list_front(const struct rt_list *list);
|
|
|
|
void rt_list_push_back(struct rt_list *list, struct rt_list *node);
|
|
|
|
// Insert node into list at the first position where cmp(node, node->next).
|
|
void rt_list_insert_by(struct rt_list *list, struct rt_list *node,
|
|
bool (*cmp)(const struct rt_list *,
|
|
const struct rt_list *));
|
|
|
|
struct rt_list
|
|
{
|
|
struct rt_list *prev, *next;
|
|
};
|
|
|
|
#define RT_LIST_INIT(name) \
|
|
{ \
|
|
.prev = &name, .next = &name \
|
|
}
|
|
|
|
#define RT_LIST(name) struct rt_list name = RT_LIST_INIT(name)
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|