File: str_map.h

package info (click to toggle)
libhat-trie 0.1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 260 kB
  • sloc: ansic: 2,345; makefile: 39; sh: 17
file content (54 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * Copyright (c) 2011 by Daniel C. Jones <dcjones@cs.washington.edu>
 *
 * hash :
 * A quick and simple hash table mapping strings to things.
 *
 */


#ifndef ISOLATOR_STR_MAP_H
#define ISOLATOR_STR_MAP_H

#if defined(__cplusplus)
extern "C" {
#endif

#include <stdlib.h>
#include <stdint.h>

#include "common.h"


typedef struct str_map_pair_
{
    char*         key;
    size_t        keylen;
    value_t       value;

    struct str_map_pair_* next;
} str_map_pair;


typedef struct
{
    str_map_pair** A; /* table proper */
    size_t n;         /* table size */
    size_t m;         /* hashed items */
    size_t max_m;     /* max hashed items before rehash */
} str_map;



str_map* str_map_create(void);
void     str_map_destroy(str_map*);
void     str_map_set(str_map*, const char* key, size_t keylen, value_t value);
value_t  str_map_get(const str_map*, const char* key, size_t keylen);
void     str_map_del(str_map* T, const char* key, size_t keylen);

#if defined(__cplusplus)
}
#endif

#endif