~jakub/helenos/ia64-revival

« back to all changes in this revision

Viewing changes to uspace/lib/c/include/adt/hash_table.h

  • Committer: Jakub Jermar
  • Date: 2011-04-13 14:45:41 UTC
  • mfrom: (527.1.397 main-clone)
  • Revision ID: jakub@jermar.eu-20110413144541-x0j3r1zxqhsljx1o
MergeĀ mainlineĀ changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
typedef unsigned long hash_count_t;
42
42
typedef unsigned long hash_index_t;
43
 
typedef struct hash_table hash_table_t;
44
 
typedef struct hash_table_operations hash_table_operations_t;
45
 
 
46
 
/** Hash table structure. */
47
 
struct hash_table {
48
 
        link_t *entry;
49
 
        hash_count_t entries;
50
 
        hash_count_t max_keys;
51
 
        hash_table_operations_t *op;
52
 
};
53
43
 
54
44
/** Set of operations for hash table. */
55
 
struct hash_table_operations {
 
45
typedef struct {
56
46
        /** Hash function.
57
47
         *
58
 
         * @param key   Array of keys needed to compute hash index. All keys
59
 
         *              must be passed.
60
 
         *
61
 
         * @return      Index into hash table.
 
48
         * @param key Array of keys needed to compute hash index.
 
49
         *            All keys must be passed.
 
50
         *
 
51
         * @return Index into hash table.
 
52
         *
62
53
         */
63
 
        hash_index_t (* hash)(unsigned long key[]);
 
54
        hash_index_t (*hash)(unsigned long key[]);
64
55
        
65
56
        /** Hash table item comparison function.
66
57
         *
67
 
         * @param key   Array of keys that will be compared with item. It is
68
 
         *              not necessary to pass all keys.
69
 
         *
70
 
         * @return      true if the keys match, false otherwise.
 
58
         * @param key Array of keys that will be compared with item. It is
 
59
         *            not necessary to pass all keys.
 
60
         *
 
61
         * @return True if the keys match, false otherwise.
 
62
         *
71
63
         */
72
64
        int (*compare)(unsigned long key[], hash_count_t keys, link_t *item);
73
 
 
 
65
        
74
66
        /** Hash table item removal callback.
75
67
         *
76
 
         * @param item  Item that was removed from the hash table.
 
68
         * @param item Item that was removed from the hash table.
 
69
         *
77
70
         */
78
71
        void (*remove_callback)(link_t *item);
79
 
};
 
72
} hash_table_operations_t;
 
73
 
 
74
/** Hash table structure. */
 
75
typedef struct {
 
76
        link_t *entry;
 
77
        hash_count_t entries;
 
78
        hash_count_t max_keys;
 
79
        hash_table_operations_t *op;
 
80
} hash_table_t;
80
81
 
81
82
#define hash_table_get_instance(item, type, member) \
82
83
    list_get_instance((item), type, member)