-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash.h
38 lines (31 loc) · 1.08 KB
/
hash.h
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
#ifndef _TREE_H
#define _TREE_H
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct HashTable
{
unsigned int capacity;
unsigned int nel;
void **data;
int (*hash)(void *, int );
int (*compar)(const void *, const void *);
};
struct Performance
{
unsigned int reads;
unsigned int writes;
unsigned int mallocs;
unsigned int frees;
};
struct Performance *newPerformance();
struct HashTable *createTable( struct Performance *performance, unsigned int capacity,
int (*hash)( void *, int ), int (*compar)(const void *, const void *) );
void addElement( struct Performance *performance, struct HashTable *table, void *src );
int getIdx( struct Performance *performance, struct HashTable *table, void *src );
void freeTable( struct Performance *performance, struct HashTable *table );
void *getElement( struct Performance *performance, struct HashTable *table, void *src );
void removeElement( struct Performance *performance, struct HashTable *table, void *target );
int hashAccuracy( struct HashTable *table );
void rehash( struct HashTable *table );
#endif