162134088SJérôme Duval/*
2173f54f1SMatt Madia * Copyright 2008-2012 Haiku, Inc. All Rights Reserved.
362134088SJérôme Duval * Distributed under the terms of the MIT License.
462134088SJérôme Duval */
562134088SJérôme Duval#ifndef _SEARCH_H_
662134088SJérôme Duval#define _SEARCH_H_
762134088SJérôme Duval
83b2c863fSAxel Dörfler
93b2c863fSAxel Dörfler#include <sys/types.h>
103b2c863fSAxel Dörfler
113b2c863fSAxel Dörfler
12173f54f1SMatt Madiatypedef enum {
13173f54f1SMatt Madia	FIND,
14173f54f1SMatt Madia	ENTER
1562134088SJérôme Duval} ACTION;
1662134088SJérôme Duval
1762134088SJérôme Duvaltypedef struct entry {
18a3b79608SJérôme Duval	char *key;
1962134088SJérôme Duval	void *data;
2062134088SJérôme Duval} ENTRY;
2162134088SJérôme Duval
2262134088SJérôme Duvaltypedef enum {
2362134088SJérôme Duval	preorder,
2462134088SJérôme Duval	postorder,
2562134088SJérôme Duval	endorder,
2662134088SJérôme Duval	leaf
2762134088SJérôme Duval} VISIT;
2862134088SJérôme Duval
2962134088SJérôme Duval
303b2c863fSAxel Dörfler#ifdef __cplusplus
313b2c863fSAxel Dörflerextern "C" {
323b2c863fSAxel Dörfler#endif
333b2c863fSAxel Dörfler
343b2c863fSAxel Dörflerextern int hcreate(size_t elementCount);
3562134088SJérôme Duvalextern void hdestroy(void);
363b2c863fSAxel Dörflerextern ENTRY *hsearch(ENTRY iteam, ACTION action);
373b2c863fSAxel Dörflerextern void insque(void *element, void *insertAfter);
383b2c863fSAxel Dörflerextern void *lfind(const void *key, const void *base, size_t *_elementCount,
393b2c863fSAxel Dörfler	size_t width, int (*compareFunction)(const void *, const void *));
403b2c863fSAxel Dörflerextern void  *lsearch(const void *key, void *base, size_t *_elementCount,
413b2c863fSAxel Dörfler	size_t width, int (*compareFunction)(const void *, const void *));
423b2c863fSAxel Dörflerextern void remque(void *element);
433b2c863fSAxel Dörflerextern void *tdelete(const void *key, void **_root,
443b2c863fSAxel Dörfler	int (*compare)(const void *, const void *));
453b2c863fSAxel Dörflerextern void *tfind(const void *key, void *const *root,
463b2c863fSAxel Dörfler	int (*compare)(const void *, const void *));
473b2c863fSAxel Dörflerextern void *tsearch(const void *key, void **_root,
483b2c863fSAxel Dörfler	int (*compare)(const void *, const void *));
493b2c863fSAxel Dörflerextern void twalk(const void *root,
503b2c863fSAxel Dörfler	void (*action)(const void *, VISIT, int ));
513b2c863fSAxel Dörfler
523b2c863fSAxel Dörfler#ifdef __cplusplus
533b2c863fSAxel Dörfler}
543b2c863fSAxel Dörfler#endif
5562134088SJérôme Duval
563b2c863fSAxel Dörfler#endif	/* _SEARCH_H_ */
57