未验证 提交 b568c8f8 编写于 作者: O openharmony_ci 提交者: Gitee

!745 提供接口检查hashmap是否为空

Merge pull request !745 from Mupceet/hashempty
...@@ -52,6 +52,7 @@ typedef struct { ...@@ -52,6 +52,7 @@ typedef struct {
typedef void *HashMapHandle; typedef void *HashMapHandle;
int HashMapIsEmpty(HashMapHandle handle);
int32_t HashMapCreate(HashMapHandle *handle, const HashInfo *info); int32_t HashMapCreate(HashMapHandle *handle, const HashInfo *info);
void HashMapDestory(HashMapHandle handle); void HashMapDestory(HashMapHandle handle);
int32_t HashMapAdd(HashMapHandle handle, HashNode *hashNode); int32_t HashMapAdd(HashMapHandle handle, HashNode *hashNode);
......
...@@ -181,3 +181,16 @@ void HashMapTraverse(HashMapHandle handle, void (*hashNodeTraverse)(const HashNo ...@@ -181,3 +181,16 @@ void HashMapTraverse(HashMapHandle handle, void (*hashNodeTraverse)(const HashNo
} }
} }
} }
int HashMapIsEmpty(HashMapHandle handle)
{
INIT_ERROR_CHECK(handle != NULL, return 1, "Invalid param");
HashTab *tab = (HashTab *)handle;
for (int i = 0; i < tab->maxBucket; i++) {
HashNode *node = tab->buckets[i];
if (node != NULL) {
return 0;
}
}
return 1;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册