Whamcloud - gitweb
Land b1_2 onto HEAD (20040304_171022)
[fs/lustre-release.git] / lnet / ulnds / table.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (c) 2002 Cray Inc.
5  *  Copyright (c) 2002 Eric Hoffman
6  *
7  *   This file is part of Portals, http://www.sf.net/projects/sandiaportals/
8  */
9
10 #ifndef E_TABLE
11 #define E_TABLE
12
13 typedef struct table_entry {
14   unsigned int key;
15   void *value;
16   struct table_entry *next;
17 } *table_entry;
18
19
20 typedef struct table {
21   unsigned int size;
22   int number_of_entries;
23   table_entry *entries;
24   int (*compare_function)(void *, void *);
25   unsigned int (*key_function)(unsigned int *);
26 } *table;
27
28 /* table.c */
29 unsigned int key_from_int(int i);
30 unsigned int key_from_string(char *s);
31 table hash_create_table(int (*compare_function)(void *, void *), unsigned int (*key_function)(unsigned int *));
32 void *hash_table_find(table t, void *comparator);
33 void hash_table_insert(table t, void *value, void *comparator);
34 void hash_table_remove(table t, void *comparator);
35 void hash_iterate_table_entries(table t, void (*handler)(void *, void *), void *arg);
36 void hash_filter_table_entries(table t, int (*handler)(void *, void *), void *arg);
37 void hash_destroy_table(table t, void (*thunk)(void *));
38
39 #endif