Ignore:
Timestamp:
2011-06-01T08:43:42Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8d6c1f1
Parents:
9e2e715 (diff), e51a514 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Huuuuuge merge from development - all the work actually :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/hash_table.h

    r9e2e715 reb522e8  
    3838#include <adt/list.h>
    3939#include <unistd.h>
     40#include <bool.h>
    4041
    4142typedef unsigned long hash_count_t;
    4243typedef unsigned long hash_index_t;
    43 typedef struct hash_table hash_table_t;
    44 typedef struct hash_table_operations hash_table_operations_t;
     44
     45/** Set of operations for hash table. */
     46typedef struct {
     47        /** Hash function.
     48         *
     49         * @param key Array of keys needed to compute hash index.
     50         *            All keys must be passed.
     51         *
     52         * @return Index into hash table.
     53         *
     54         */
     55        hash_index_t (*hash)(unsigned long key[]);
     56       
     57        /** Hash table item comparison function.
     58         *
     59         * @param key Array of keys that will be compared with item. It is
     60         *            not necessary to pass all keys.
     61         *
     62         * @return True if the keys match, false otherwise.
     63         *
     64         */
     65        int (*compare)(unsigned long key[], hash_count_t keys, link_t *item);
     66       
     67        /** Hash table item removal callback.
     68         *
     69         * @param item Item that was removed from the hash table.
     70         *
     71         */
     72        void (*remove_callback)(link_t *item);
     73} hash_table_operations_t;
    4574
    4675/** Hash table structure. */
    47 struct hash_table {
     76typedef struct {
    4877        link_t *entry;
    4978        hash_count_t entries;
    5079        hash_count_t max_keys;
    5180        hash_table_operations_t *op;
    52 };
    53 
    54 /** Set of operations for hash table. */
    55 struct hash_table_operations {
    56         /** Hash function.
    57          *
    58          * @param key   Array of keys needed to compute hash index. All keys
    59          *              must be passed.
    60          *
    61          * @return      Index into hash table.
    62          */
    63         hash_index_t (* hash)(unsigned long key[]);
    64        
    65         /** Hash table item comparison function.
    66          *
    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.
    71          */
    72         int (*compare)(unsigned long key[], hash_count_t keys, link_t *item);
    73 
    74         /** Hash table item removal callback.
    75          *
    76          * @param item  Item that was removed from the hash table.
    77          */
    78         void (*remove_callback)(link_t *item);
    79 };
     81} hash_table_t;
    8082
    8183#define hash_table_get_instance(item, type, member) \
    8284    list_get_instance((item), type, member)
    8385
    84 extern int hash_table_create(hash_table_t *, hash_count_t, hash_count_t,
     86extern bool hash_table_create(hash_table_t *, hash_count_t, hash_count_t,
    8587    hash_table_operations_t *);
    8688extern void hash_table_insert(hash_table_t *, unsigned long [], link_t *);
Note: See TracChangeset for help on using the changeset viewer.