2023-10-14 13:50:37 -07:00
|
|
|
#pragma once
|
2018-08-23 02:43:03 -07:00
|
|
|
|
2018-09-11 02:12:18 -07:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2023-07-06 23:55:29 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2024-05-16 22:21:57 -07:00
|
|
|
struct rt_list;
|
2018-08-23 02:43:03 -07:00
|
|
|
|
2022-08-07 11:21:12 -07:00
|
|
|
void rt_list_remove(struct rt_list *node);
|
2018-09-11 02:12:18 -07:00
|
|
|
|
2022-10-19 22:15:51 -07:00
|
|
|
bool rt_list_is_empty(const struct rt_list *list);
|
2018-09-05 21:04:35 -07:00
|
|
|
|
2022-10-20 23:34:41 -07:00
|
|
|
struct rt_list *rt_list_front(const struct rt_list *list);
|
2018-09-07 02:30:08 -07:00
|
|
|
|
2023-02-04 03:52:23 -08:00
|
|
|
void rt_list_push_back(struct rt_list *list, struct rt_list *node);
|
|
|
|
|
2023-10-14 13:50:37 -07:00
|
|
|
// Insert node into list at the first position where cmp(node, node->next).
|
2022-10-26 08:50:23 -07:00
|
|
|
void rt_list_insert_by(struct rt_list *list, struct rt_list *node,
|
2023-06-06 22:10:37 -07:00
|
|
|
bool (*cmp)(const struct rt_list *,
|
|
|
|
const struct rt_list *));
|
2022-10-26 08:50:23 -07:00
|
|
|
|
2024-05-16 22:21:57 -07:00
|
|
|
struct rt_list
|
|
|
|
{
|
|
|
|
struct rt_list *prev, *next;
|
|
|
|
};
|
|
|
|
|
2022-10-19 22:15:51 -07:00
|
|
|
#define RT_LIST_INIT(name) \
|
|
|
|
{ \
|
|
|
|
.prev = &name, .next = &name \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_LIST(name) struct rt_list name = RT_LIST_INIT(name)
|
|
|
|
|
2023-07-06 23:55:29 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|