2008-02-24 16:41:01 +03:00
|
|
|
/*
|
2012-07-19 22:11:40 +04:00
|
|
|
* Copyright 2008-2012 Haiku, Inc. All Rights Reserved.
|
2008-02-24 16:41:01 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _SEARCH_H_
|
|
|
|
#define _SEARCH_H_
|
|
|
|
|
2008-06-06 11:42:58 +04:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
|
2012-07-19 22:11:40 +04:00
|
|
|
typedef enum {
|
|
|
|
FIND,
|
|
|
|
ENTER
|
2008-02-24 16:41:01 +03:00
|
|
|
} ACTION;
|
|
|
|
|
|
|
|
typedef struct entry {
|
2014-06-07 12:34:09 +04:00
|
|
|
char *key;
|
2008-02-24 16:41:01 +03:00
|
|
|
void *data;
|
|
|
|
} ENTRY;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
preorder,
|
|
|
|
postorder,
|
|
|
|
endorder,
|
|
|
|
leaf
|
|
|
|
} VISIT;
|
|
|
|
|
|
|
|
|
2008-06-06 11:42:58 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int hcreate(size_t elementCount);
|
2008-02-24 16:41:01 +03:00
|
|
|
extern void hdestroy(void);
|
2008-06-06 11:42:58 +04:00
|
|
|
extern ENTRY *hsearch(ENTRY iteam, ACTION action);
|
|
|
|
extern void insque(void *element, void *insertAfter);
|
|
|
|
extern void *lfind(const void *key, const void *base, size_t *_elementCount,
|
|
|
|
size_t width, int (*compareFunction)(const void *, const void *));
|
|
|
|
extern void *lsearch(const void *key, void *base, size_t *_elementCount,
|
|
|
|
size_t width, int (*compareFunction)(const void *, const void *));
|
|
|
|
extern void remque(void *element);
|
|
|
|
extern void *tdelete(const void *key, void **_root,
|
|
|
|
int (*compare)(const void *, const void *));
|
|
|
|
extern void *tfind(const void *key, void *const *root,
|
|
|
|
int (*compare)(const void *, const void *));
|
|
|
|
extern void *tsearch(const void *key, void **_root,
|
|
|
|
int (*compare)(const void *, const void *));
|
|
|
|
extern void twalk(const void *root,
|
|
|
|
void (*action)(const void *, VISIT, int ));
|
|
|
|
|
2021-09-17 22:34:10 +03:00
|
|
|
#ifdef _GNU_SOURCE
|
2021-09-17 22:35:51 +03:00
|
|
|
extern void tdestroy(void *root, void (*free_key)(void *));
|
2021-09-17 22:34:10 +03:00
|
|
|
#endif
|
|
|
|
|
2008-06-06 11:42:58 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2008-02-24 16:41:01 +03:00
|
|
|
|
2008-06-06 11:42:58 +04:00
|
|
|
#endif /* _SEARCH_H_ */
|