summaryrefslogtreecommitdiff
path: root/minilib/hash.h
blob: 1aaf8ed307c66a57d053b2f8875af6e9ffb97b4b (plain)
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
#pragma once

typedef struct intHashEntry {
	char *key;
	int value;
	struct intHashEntry *next;
} intHashEntry;

typedef struct intHashTable {
	int capacity;
	int size;
	intHashEntry **table;
} intHashTable;

typedef struct intHashIterator {
	int pos;
	intHashEntry *entry;
	intHashTable *ht;
} intHashIterator;

void inthash_init( intHashTable *ht, int size );
void inthash_done( intHashTable *ht );
void inthash_set( intHashTable *ht, char *key, int value );
int inthash_get( intHashTable *ht, char *key );
intHashEntry *inthash_getfirst( intHashTable *ht, intHashIterator *it );
intHashEntry *inthash_getnext( intHashIterator *it );