kernel-dev/include/libk/lst.h

41 lines
939 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef LST_H
#define LST_H 1
/*
Line Search Table
线段搜索表
*/
#include <types.h>
typedef struct __lst_line_t
{
usize left, right;
} lst_line_t;
typedef struct __lst_iterator_t
{
lst_line_t line;
struct __lst_iterator_t *next;
} lst_iterator_t;
lst_iterator_t *lst_new(usize start, usize end);
lst_iterator_t *lst_next(lst_iterator_t *iterator);
/*
在`lst`中移除一个线段[left,right)
force=true时忽略不存在于`lst`中的线段
force=false时若有不存在于`lst`中的线段不移除任何线段返回false否则返回true
*/
bool lst_remove(lst_iterator_t *lst, usize left, usize right, bool force);
/*
在`lst`中添加一个线段[left,right)
force=true时忽略已经存在于`lst`中的线段
force=false时若有存在于`lst`中的线段不添加任何线段返回false否则返回true
*/
bool lst_add(lst_iterator_t *lst, usize left, usize right, bool force);
#endif