TuyaOS
宏定义 | 类型定义 | 函数
tuya_hashmap.h 文件参考

tuya hasmap module 更多...

#include "tuya_cloud_types.h"
tuya_hashmap.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

宏定义

#define MAP_MISSING   -2 /* No such element */
 define some special error code for hashmap module
 
#define MAP_OK   0 /* OK */
 
#define MAP_OMEM   -1 /* Out of Memory */
 
#define TUYA_HASHMAP_FOR_EACH_DATA(in, key, data_iter)    for(data_iter = NULL; tuya_hashmap_data_traversal(in, key, (ANY_T_ITER *)&data_iter) == MAP_OK; /*empty*/)
 traverse all data with same key
 

类型定义

typedef void * ANY_T
 any_t is a pointer. This allows you to put arbitrary structures in the hashmap.
 
typedef ANY_TANY_T_ITER
 any_t_iter is a iterator which used to traverse the hashmap
 
typedef ANY_T MAP_T
 map_t is a pointer to an internally maintained data structure. Clients of this package do not need to know how hashmaps are represented. They see and manipulate only map_t's.
 

函数

INT_T tuya_hashmap_data_traversal (MAP_T in, const CHAR_T *key, ANY_T_ITER *arg_iterator)
 traverse all data with same key 更多...
 
void tuya_hashmap_free (MAP_T in)
 free the hashmap 更多...
 
INT_T tuya_hashmap_get (MAP_T in, const CHAR_T *key, ANY_T *arg)
 get an element from the hashmap 更多...
 
INT_T tuya_hashmap_length (MAP_T in)
 get current size of the hashmap 更多...
 
MAP_T tuya_hashmap_new (UINT_T table_size)
 create a new empty hashmap 更多...
 
INT_T tuya_hashmap_put (MAP_T in, const CHAR_T *key, const ANY_T data)
 Add an element to the hashmap 更多...
 
INT_T tuya_hashmap_remove (MAP_T in, CHAR_T *key, ANY_T data)
 remove an element from the hashmap 更多...
 

详细描述

tuya hasmap module

版本
1.0
日期
2019-10-30

函数说明

◆ tuya_hashmap_data_traversal()

INT_T tuya_hashmap_data_traversal ( MAP_T  in,
const CHAR_T *  key,
ANY_T_ITER arg_iterator 
)

traverse all data with same key

参数
[in]inthe hashmap
[in]keythe key of element
[in,out]arg_iteratorthe traverse iterator
返回
MAP_OK on success, others on failed, please refer to the define of hashmap error code
注解
if arg_iterator is NULL, fetch the first element, otherwise, fetch the next element

◆ tuya_hashmap_free()

void tuya_hashmap_free ( MAP_T  in)

free the hashmap

参数
[in]inthe hashmap need to free
警告
must remove all element first, otherwise, it will cause element leak

◆ tuya_hashmap_get()

INT_T tuya_hashmap_get ( MAP_T  in,
const CHAR_T *  key,
ANY_T arg 
)

get an element from the hashmap

参数
[in]inthe hashmap
[in]keythe key of the element
[out]argthe first value that the key matches
返回
MAP_OK on success, others on failed, please refer to the define of hashmap error code

◆ tuya_hashmap_length()

INT_T tuya_hashmap_length ( MAP_T  in)

get current size of the hashmap

参数
[in]inthe hashmap
返回
the current size

◆ tuya_hashmap_new()

MAP_T tuya_hashmap_new ( UINT_T  table_size)

create a new empty hashmap

参数
[in]table_sizethe hash table size
返回
a new empty hashmap

◆ tuya_hashmap_put()

INT_T tuya_hashmap_put ( MAP_T  in,
const CHAR_T *  key,
const ANY_T  data 
)

Add an element to the hashmap

参数
[in]inthe hashmap
[in]keythe key of hash element
[in]datathe data of hash element
返回
MAP_OK on success, others on failed, please refer to the define of hashmap error code
注解
For same key, it does not replace it. it is inserted in the head of the list

◆ tuya_hashmap_remove()

INT_T tuya_hashmap_remove ( MAP_T  in,
CHAR_T *  key,
ANY_T  data 
)

remove an element from the hashmap

参数
[in]inthe hashmap
[in]keythe key of element
[in]datathe data of the element
返回
MAP_OK on success, others on failed, please refer to the define of hashmap error code
注解
if data is NULL,then delete the first note match key.if data is not null, then delete the node match key and data.