| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef _COLLECTION_H_ |
| 18 |
#define _COLLECTION_H_ |
| 19 |
|
| 20 |
#ifdef __cplusplus |
| 21 |
extern "C" |
| 22 |
{ |
| 23 |
#endif |
| 24 |
|
| 25 |
typedef struct hashable |
| 26 |
{ |
| 27 |
struct hashable *next; |
| 28 |
char *key; |
| 29 |
unsigned long count; |
| 30 |
} hashable_t; |
| 31 |
|
| 32 |
typedef struct hashtable |
| 33 |
{ |
| 34 |
unsigned int capacity; |
| 35 |
unsigned int elements; |
| 36 |
unsigned int uniq; |
| 37 |
hashable_t **table; |
| 38 |
char **keys; |
| 39 |
} hashtable_t; |
| 40 |
|
| 41 |
hashtable_t *counter_create (void); |
| 42 |
void counter_free (hashtable_t * hashtable); |
| 43 |
|
| 44 |
hashable_t *counter_lookup (const hashtable_t * hashtable, const char *key); |
| 45 |
hashable_t *counter_put (hashtable_t * hashtable, const char *key, |
| 46 |
unsigned long increment); |
| 47 |
unsigned int counter_get_elements (const hashtable_t * hashtable); |
| 48 |
unsigned int counter_get_unique_elements (const hashtable_t * hashtable); |
| 49 |
char **counter_keys (hashtable_t * hashtable); |
| 50 |
|
| 51 |
#ifdef __cplusplus |
| 52 |
} |
| 53 |
#endif |
| 54 |
|
| 55 |
#endif |