/[cvs]/eggdrop1.9/src/egglib/hash_table_test.c
ViewVC logotype

Contents of /eggdrop1.9/src/egglib/hash_table_test.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Sun Oct 28 13:30:35 2001 UTC (17 years, 11 months ago) by ite
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/x-chdr
FILE REMOVED
Renamed src/adns, src/compat, src/egglib to lib/adns, lib/compat, lib/egglib respectively.

1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "hash_table.h"
4
5 int my_node_func(void *key, void *data, void *param)
6 {
7 printf("my_node_func: %d, %d\n", key, data);
8 return(0);
9 }
10
11 int main ()
12 {
13 hash_table_t *ht;
14 int data, i;
15
16 ht = hash_table_create(NULL, NULL, 3, HASH_TABLE_INTS);
17
18 srand(time(NULL));
19 printf("Creating hash table...\n");
20 for (i = 0; i < 10; i++) {
21 hash_table_insert(ht, (void *)i, (void *)i);
22 }
23
24 printf("first walk:\n");
25 hash_table_walk(ht, my_node_func, NULL);
26 //hash_table_delete(ht, (void *)5);
27 //hash_table_delete(ht, (void *)5);
28 hash_table_delete(ht, (void *)8);
29 hash_table_delete(ht, (void *)2);
30 hash_table_delete(ht, (void *)2);
31 printf("second walk:\n");
32 hash_table_walk(ht, my_node_func, NULL);
33
34 printf("Retrieving from hash table...\n");
35 for (i = 0; i < 10; i++) {
36 if (hash_table_find(ht, (void *)i, &data)) {
37 printf("key not found: %d\n", i);
38 }
39 else if (i != data) {
40 printf("key %d has wrong data: %d\n", i, data);
41 }
42 }
43 return(0);
44 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23