Lines Matching +full:non +full:- +full:linear

27  * Provides multiple, dynamically-allocated, variable-sized hash tables on
77 + sizeof(hash_member *) * (tablesize - 1); in hash_Init()
81 hashtblptr->size = tablesize; /* Success! */ in hash_Init()
82 hashtblptr->bucketnum = 0; in hash_Init()
83 hashtblptr->member = (hashtblptr->table)[0]; in hash_Init()
86 hashtblptr = NULL; /* Disallow zero-length tables */ in hash_Init()
103 nextbucket = bucketptr->next; in hashi_FreeMembers()
104 (*free_data) (bucketptr->data); in hashi_FreeMembers()
114 * This routine re-initializes the hash table. It frees all the allocated
124 bucketptr = hashtable->table; in hash_Reset()
125 for (i = 0; i < hashtable->size; i++) { in hash_Reset()
129 hashtable->bucketnum = 0; in hash_Reset()
130 hashtable->member = (hashtable->table)[0]; in hash_Reset()
138 * For each byte of the string, this function left-shifts the value in an
161 for (; len > 0; len--) { in hash_HashFunction()
181 memberptr = (hashtable->table)[hashcode % (hashtable->size)]; in hash_Exists()
183 if ((*compare) (key, memberptr->data)) { in hash_Exists()
186 memberptr = memberptr->next; in hash_Exists()
200 * occurs, -1 is returned and the insertion is not done.
209 hashcode %= hashtable->size; in hash_Insert()
211 return -1; /* At least one entry already exists */ in hash_Insert()
215 return -1; /* malloc failed! */ in hash_Insert()
217 temp->data = element; in hash_Insert()
218 temp->next = (hashtable->table)[hashcode]; in hash_Insert()
219 (hashtable->table)[hashcode] = temp; in hash_Insert()
228 * If no matching elements can be found in the hash table, -1 is returned.
239 retval = -1; in hash_Delete()
240 hashcode %= hashtable->size; in hash_Delete()
247 memberptr = (hashtable->table)[hashcode]; in hash_Delete()
248 while (memberptr && (*compare) (key, memberptr->data)) { in hash_Delete()
249 (hashtable->table)[hashcode] = memberptr->next; in hash_Delete()
253 memberptr->next = NULL; in hash_Delete()
255 memberptr = (hashtable->table)[hashcode]; in hash_Delete()
264 memberptr = memberptr->next; in hash_Delete()
267 if ((*compare) (key, memberptr->data)) { in hash_Delete()
269 previous->next = memberptr = memberptr->next; in hash_Delete()
273 tempptr->next = NULL; in hash_Delete()
278 memberptr = memberptr->next; in hash_Delete()
299 memberptr = (hashtable->table)[hashcode % (hashtable->size)]; in hash_Lookup()
301 if ((*compare) (key, memberptr->data)) { in hash_Lookup()
302 return (memberptr->data); in hash_Lookup()
304 memberptr = memberptr->next; in hash_Lookup()
312 * Return the next available entry in the hashtable for a linear search
324 memberptr = hashtable->member; in hash_NextEntry()
326 hashtable->member = memberptr->next; /* Set up for next call */ in hash_NextEntry()
327 return memberptr->data; /* Return the data */ in hash_NextEntry()
331 * until we find a new chain (non-empty bucket) or run out of buckets. in hash_NextEntry()
333 bucket = hashtable->bucketnum + 1; in hash_NextEntry()
334 while ((bucket < hashtable->size) && in hash_NextEntry()
335 !(memberptr = (hashtable->table)[bucket])) { in hash_NextEntry()
342 if (bucket >= hashtable->size) { in hash_NextEntry()
346 hashtable->bucketnum = 0; in hash_NextEntry()
347 hashtable->member = (hashtable->table)[0]; in hash_NextEntry()
349 * But return end-of-table indication to the caller this time. in hash_NextEntry()
354 * Must have found a non-empty bucket. in hash_NextEntry()
356 hashtable->bucketnum = bucket; in hash_NextEntry()
357 hashtable->member = memberptr->next; /* Set up for next call */ in hash_NextEntry()
358 return memberptr->data; /* Return the data */ in hash_NextEntry()
364 * Return the first entry in a hash table for a linear search
370 hashtable->bucketnum = 0; in hash_FirstEntry()
371 hashtable->member = (hashtable->table)[0]; in hash_FirstEntry()
377 * tab-width: 4
378 * c-indent-level: 4
379 * c-argdecl-indent: 4
380 * c-continued-statement-offset: 4
381 * c-continued-brace-offset: -4
382 * c-label-offset: -4
383 * c-brace-offset: 0