rt/include/rt/list.h

39 lines
978 B
C
Raw Normal View History

#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
bool rt_list_is_empty(const struct rt_list *list);
struct rt_list *rt_list_front(const struct rt_list *list);
2018-09-07 02:30:08 -07:00
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 *));
2024-05-16 22:21:57 -07:00
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)
2023-07-06 23:55:29 -07:00
#ifdef __cplusplus
}
#endif