search.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020: #ifndef _SEARCH_H
021: #define _SEARCH_H 1
022:
023: #include <features.h>
024:
025: #define __need_size_t
026: #include <stddef.h>
027:
028: __BEGIN_DECLS
029:
030: #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
031:
032:
033:
034: # ifdef __USE_GNU
035: struct qelem
036: {
037: struct qelem *q_forw;
038: struct qelem *q_back;
039: char q_data[1];
040: };
041: # endif
042:
043:
044:
045: extern void insque (void *__elem, void *__prev) __THROW;
046:
047:
048: extern void remque (void *__elem) __THROW;
049: #endif
050:
051:
052:
053: #ifndef __COMPAR_FN_T
054: # define __COMPAR_FN_T
055: typedef int (*__compar_fn_t) (__const void *, __const void *);
056:
057: # ifdef __USE_GNU
058: typedef __compar_fn_t comparison_fn_t;
059: # endif
060: #endif
061:
062:
063: typedef enum
064: {
065: FIND,
066: ENTER
067: }
068: ACTION;
069:
070: typedef struct entry
071: {
072: char *key;
073: void *data;
074: }
075: ENTRY;
076:
077:
078: struct _ENTRY;
079:
080:
081:
082:
083:
084:
085:
086:
087:
088: extern ENTRY *hsearch (ENTRY __item, ACTION __action) __THROW;
089:
090:
091: extern int hcreate (size_t __nel) __THROW;
092:
093:
094: extern void hdestroy (void) __THROW;
095:
096: #ifdef __USE_GNU
097:
098: struct hsearch_data
099: {
100: struct _ENTRY *table;
101: unsigned int size;
102: unsigned int filled;
103: };
104:
105:
106:
107: extern int hsearch_r (ENTRY __item, ACTION __action, ENTRY **__retval,
108: struct hsearch_data *__htab) __THROW;
109: extern int hcreate_r (size_t __nel, struct hsearch_data *__htab) __THROW;
110: extern void hdestroy_r (struct hsearch_data *__htab) __THROW;
111: #endif
112:
113:
114:
115:
116:
117:
118:
119: typedef enum
120: {
121: preorder,
122: postorder,
123: endorder,
124: leaf
125: }
126: VISIT;
127:
128:
129:
130: extern void *tsearch (__const void *__key, void **__rootp,
131: __compar_fn_t __compar);
132:
133:
134:
135: extern void *tfind (__const void *__key, void *__const *__rootp,
136: __compar_fn_t __compar);
137:
138:
139: extern void *tdelete (__const void *__restrict __key,
140: void **__restrict __rootp,
141: __compar_fn_t __compar);
142:
143: #ifndef __ACTION_FN_T
144: # define __ACTION_FN_T
145: typedef void (*__action_fn_t) (__const void *__nodep, VISIT __value,
146: int __level);
147: #endif
148:
149:
150:
151: extern void twalk (__const void *__root, __action_fn_t __action);
152:
153: #ifdef __USE_GNU
154:
155:
156: typedef void (*__free_fn_t) (void *__nodep);
157:
158:
159: extern void tdestroy (void *__root, __free_fn_t __freefct);
160: #endif
161:
162:
163:
164:
165: extern void *lfind (__const void *__key, __const void *__base,
166: size_t *__nmemb, size_t __size, __compar_fn_t __compar);
167:
168:
169:
170: extern void *lsearch (__const void *__key, void *__base,
171: size_t *__nmemb, size_t __size, __compar_fn_t __compar);
172:
173: __END_DECLS
174:
175: #endif
176:
© Andrew Scott 2006 -
2026,
All Rights Reserved