1/*
2 * Copyright 2008-2012 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _SEARCH_H_
6#define _SEARCH_H_
7
8
9#include <sys/types.h>
10
11
12typedef enum {
13	FIND,
14	ENTER
15} ACTION;
16
17typedef struct entry {
18	char *key;
19	void *data;
20} ENTRY;
21
22typedef enum {
23	preorder,
24	postorder,
25	endorder,
26	leaf
27} VISIT;
28
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34extern int hcreate(size_t elementCount);
35extern void hdestroy(void);
36extern ENTRY *hsearch(ENTRY iteam, ACTION action);
37extern void insque(void *element, void *insertAfter);
38extern void *lfind(const void *key, const void *base, size_t *_elementCount,
39	size_t width, int (*compareFunction)(const void *, const void *));
40extern void  *lsearch(const void *key, void *base, size_t *_elementCount,
41	size_t width, int (*compareFunction)(const void *, const void *));
42extern void remque(void *element);
43extern void *tdelete(const void *key, void **_root,
44	int (*compare)(const void *, const void *));
45extern void *tfind(const void *key, void *const *root,
46	int (*compare)(const void *, const void *));
47extern void *tsearch(const void *key, void **_root,
48	int (*compare)(const void *, const void *));
49extern void twalk(const void *root,
50	void (*action)(const void *, VISIT, int ));
51
52#ifdef __cplusplus
53}
54#endif
55
56#endif	/* _SEARCH_H_ */
57