TuyaOS
tuya_hashmap.h
浏览该文件的文档.
1
11#ifndef __TUYA_HASHMAP_H__
12#define __TUYA_HASHMAP_H__
13
14#include "tuya_cloud_types.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
24#define MAP_MISSING -2 /* No such element */
25#define MAP_OMEM -1 /* Out of Memory */
26#define MAP_OK 0 /* OK */
27
32typedef VOID_T *ANY_T;
33
39typedef ANY_T MAP_T;
40
46
53MAP_T tuya_hashmap_new(UINT_T table_size);
54
55
66INT_T tuya_hashmap_put(MAP_T in, CONST CHAR_T* key ,CONST ANY_T data);
67
76INT_T tuya_hashmap_get(MAP_T in, CONST CHAR_T* key, ANY_T *arg);
77
88INT_T tuya_hashmap_data_traversal(MAP_T in, CONST CHAR_T* key, ANY_T_ITER *arg_iterator);
89
94#define TUYA_HASHMAP_FOR_EACH_DATA(in, key, data_iter) \
95 for(data_iter = NULL; tuya_hashmap_data_traversal(in, key, (ANY_T_ITER *)&data_iter) == MAP_OK; /*empty*/)
96
97
108INT_T tuya_hashmap_remove(MAP_T in, CHAR_T* key, ANY_T data);
109
118
126
127#ifdef __cplusplus
128}
129#endif /* __cplusplus */
130
131#endif // __HASHMAP_H__
void tuya_hashmap_free(MAP_T in)
free the hashmap
void * ANY_T
any_t is a pointer. This allows you to put arbitrary structures in the hashmap.
Definition: tuya_hashmap.h:32
INT_T tuya_hashmap_put(MAP_T in, const CHAR_T *key, const ANY_T data)
Add an element to the hashmap
ANY_T MAP_T
map_t is a pointer to an internally maintained data structure. Clients of this package do not need to...
Definition: tuya_hashmap.h:39
ANY_T * ANY_T_ITER
any_t_iter is a iterator which used to traverse the hashmap
Definition: tuya_hashmap.h:45
INT_T tuya_hashmap_length(MAP_T in)
get current size of the hashmap
INT_T tuya_hashmap_remove(MAP_T in, CHAR_T *key, ANY_T data)
remove an element from the hashmap
INT_T tuya_hashmap_data_traversal(MAP_T in, const CHAR_T *key, ANY_T_ITER *arg_iterator)
traverse all data with same key
MAP_T tuya_hashmap_new(UINT_T table_size)
create a new empty hashmap
INT_T tuya_hashmap_get(MAP_T in, const CHAR_T *key, ANY_T *arg)
get an element from the hashmap