| 1 |
#ifndef AWS_COMMON_LINKED_HASH_TABLE_H |
| 2 |
#define AWS_COMMON_LINKED_HASH_TABLE_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#include <aws/common/hash_table.h> |
| 8 |
#include <aws/common/linked_list.h> |
| 9 |
|
| 10 |
AWS_PUSH_SANE_WARNING_LEVEL |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
struct aws_linked_hash_table { |
| 18 |
struct aws_allocator *allocator; |
| 19 |
struct aws_linked_list list; |
| 20 |
struct aws_hash_table table; |
| 21 |
aws_hash_callback_destroy_fn *user_on_value_destroy; |
| 22 |
aws_hash_callback_destroy_fn *user_on_key_destroy; |
| 23 |
}; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
struct aws_linked_hash_table_node { |
| 30 |
struct aws_linked_list_node node; |
| 31 |
struct aws_linked_hash_table *table; |
| 32 |
const void *key; |
| 33 |
void *value; |
| 34 |
}; |
| 35 |
|
| 36 |
AWS_EXTERN_C_BEGIN |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
AWS_COMMON_API |
| 44 |
int aws_linked_hash_table_init( |
| 45 |
struct aws_linked_hash_table *table, |
| 46 |
struct aws_allocator *allocator, |
| 47 |
aws_hash_fn *hash_fn, |
| 48 |
aws_hash_callback_eq_fn *equals_fn, |
| 49 |
aws_hash_callback_destroy_fn *destroy_key_fn, |
| 50 |
aws_hash_callback_destroy_fn *destroy_value_fn, |
| 51 |
size_t initial_item_count); |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
AWS_COMMON_API |
| 58 |
void aws_linked_hash_table_clean_up(struct aws_linked_hash_table *table); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
AWS_COMMON_API |
| 68 |
int aws_linked_hash_table_find(struct aws_linked_hash_table *table, const void *key, void **p_value); |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
AWS_COMMON_API |
| 78 |
int aws_linked_hash_table_find_and_move_to_back(struct aws_linked_hash_table *table, const void *key, void **p_value); |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
AWS_COMMON_API |
| 84 |
int aws_linked_hash_table_put(struct aws_linked_hash_table *table, const void *key, void *p_value); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
AWS_COMMON_API |
| 90 |
int aws_linked_hash_table_remove(struct aws_linked_hash_table *table, const void *key); |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
AWS_COMMON_API |
| 96 |
void aws_linked_hash_table_clear(struct aws_linked_hash_table *table); |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
AWS_COMMON_API |
| 102 |
size_t aws_linked_hash_table_get_element_count(const struct aws_linked_hash_table *table); |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
AWS_COMMON_API |
| 110 |
void aws_linked_hash_table_move_node_to_end_of_list( |
| 111 |
struct aws_linked_hash_table *table, |
| 112 |
struct aws_linked_hash_table_node *node); |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
AWS_COMMON_API |
| 120 |
const struct aws_linked_list *aws_linked_hash_table_get_iteration_list(const struct aws_linked_hash_table *table); |
| 121 |
|
| 122 |
AWS_EXTERN_C_END |
| 123 |
AWS_POP_SANE_WARNING_LEVEL |
| 124 |
|
| 125 |
#endif |