mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2025-04-21 12:27:27 +03:00
qpkg/: initial commit (sneak preview only, doesn't work properly yet)
This commit is contained in:
39
qpkg/id.h
Normal file
39
qpkg/id.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef ID_H
|
||||
#define ID_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
struct id;
|
||||
|
||||
/*
|
||||
* @@@ basic binary trees are not a good choice. should use rb.
|
||||
* To ease future migration, we separate the node structure from the rest.
|
||||
*/
|
||||
|
||||
struct node {
|
||||
struct node *up, *left, *right;
|
||||
};
|
||||
|
||||
struct tree {
|
||||
int (*comp)(const struct id *a, const struct id *b);
|
||||
struct node *root;
|
||||
};
|
||||
|
||||
struct id {
|
||||
struct node node;
|
||||
const char *s;
|
||||
size_t len;
|
||||
void *value;
|
||||
};
|
||||
|
||||
|
||||
int comp_id(const struct id *a, const struct id *b);
|
||||
|
||||
struct tree *make_tree(int (*comp)(const struct id *a, const struct id *b));
|
||||
struct id *make_id(struct tree *tree, const char *s, size_t len);
|
||||
const struct id *find_id(const struct tree *tree, const char *s, size_t len);
|
||||
const struct id *first_id(const struct tree *tree);
|
||||
const struct id *next_id(const struct id *id);
|
||||
|
||||
#endif /* !ID_H */
|
||||
Reference in New Issue
Block a user