ds: hashmap: update iterator interface
This commit is contained in:
@@ -12,13 +12,18 @@ B_DECLS_BEGIN;
|
||||
|
||||
struct b_hashmap_p;
|
||||
|
||||
#define B_TYPE_HASHMAP (b_hashmap_get_type())
|
||||
#define B_TYPE_HASHMAP (b_hashmap_get_type())
|
||||
#define B_TYPE_HASHMAP_ITERATOR (b_hashmap_iterator_get_type())
|
||||
|
||||
B_DECLARE_TYPE(b_hashmap);
|
||||
B_DECLARE_TYPE(b_hashmap_iterator);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_hashmap)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_hashmap)
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_hashmap_iterator)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_hashmap_iterator)
|
||||
|
||||
#define B_HASHMAP_KEY(k, ks) {.key_data = (k), .key_size = (ks)}
|
||||
#define B_HASHMAP_VALUE(v, vs) {.value_data = (v), .value_size = (vs)}
|
||||
|
||||
@@ -54,19 +59,8 @@ typedef struct b_hashmap_item {
|
||||
b_hashmap_value value;
|
||||
} b_hashmap_item;
|
||||
|
||||
typedef struct b_hashmap_iterator {
|
||||
b_iterator _base;
|
||||
size_t i;
|
||||
const b_hashmap_key *key;
|
||||
const b_hashmap_value *value;
|
||||
|
||||
b_hashmap *_h;
|
||||
struct b_hashmap_p *_h_p;
|
||||
b_btree_node *_cbn;
|
||||
b_queue_entry *_cqe;
|
||||
} b_hashmap_iterator;
|
||||
|
||||
BLUE_API b_type b_hashmap_get_type(void);
|
||||
BLUE_API b_type b_hashmap_iterator_get_type(void);
|
||||
|
||||
BLUE_API b_hashmap *b_hashmap_create(
|
||||
b_hashmap_key_destructor key_dtor, b_hashmap_value_destructor value_dtor);
|
||||
@@ -81,11 +75,6 @@ BLUE_API bool b_hashmap_has_key(const b_hashmap *hashmap, const b_hashmap_key *k
|
||||
BLUE_API size_t b_hashmap_get_size(const b_hashmap *hashmap);
|
||||
BLUE_API bool b_hashmap_is_empty(const b_hashmap *hashmap);
|
||||
|
||||
BLUE_API int b_hashmap_iterator_begin(b_hashmap *hashmap, b_hashmap_iterator *it);
|
||||
BLUE_API bool b_hashmap_iterator_next(b_hashmap_iterator *it);
|
||||
BLUE_API b_status b_hashmap_iterator_erase(b_hashmap_iterator *it);
|
||||
BLUE_API bool b_hashmap_iterator_is_valid(const b_hashmap_iterator *it);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user