1/**
2 * \file
3 * \brief Hashtable headers
4 */
5
6/*
7 * Copyright (c) 2008, 2011, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14#ifndef HASHTABLE_H_
15#define HASHTABLE_H_
16
17#include <hashtable/dictionary.h>
18#include <stdio.h>
19#include <sys/cdefs.h>
20
21__BEGIN_DECLS
22
23/**
24 * \brief an entry of a hashtable
25 */
26struct _ht_entry {
27    const void* key;
28    size_t key_len;
29    void* value;
30    struct capref capvalue;
31    ENTRY_TYPE type;
32    int hash_value;
33    struct _ht_entry *next;
34};
35
36/**
37 * \brief hashtable
38 */
39struct hashtable {
40    struct dictionary d;
41    int table_length;
42    int entry_count;
43    struct _ht_entry **entries;
44    int threshold;
45    int capacity;
46    int load_factor;
47};
48
49/**
50 * \brief create an empty hashtable with a given capacity and load factor
51 * \param capacity the capacity
52 * \param the load factor
53 * \return an empty hashtable.
54 */
55struct hashtable* create_hashtable2(int capacity, int loadFactor);
56
57/**
58 * \brief create an empty hashtable with default capacity and load factor
59 * \return an empty hashtable
60 */
61struct hashtable* create_hashtable(void);
62
63void print_hashtable(FILE *stream, struct hashtable *ht);
64
65__END_DECLS
66
67#endif /*HASHTABLE_H_*/
68