Search/Sort

This commit is contained in:
2026-08-29 01:58:00 +08:00
parent 8e95904cc4
commit a0758766c5
56 changed files with 5425 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#ifndef INCLUDED_C_HASHSET_H
#define INCLUDED_C_HASHSET_H
#ifndef INCLUDED_C_HASHMAP_H
#include <c_HashMap.h>
#endif /*INCLUDED_C_HASHMAP_H*/
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
typedef struct {
c_HashMap_t map; // 底層由 HashMap 驅動
} c_HashSet_t;
// 集合迭代器(直接重定向至您的 HashMapKeyIter
typedef c_HashMapKeyIter_t c_HashSetIter_t;
// 核心函數宣告
c_err_t c_HashSet_Init(c_HashSet_t* self, int obj_size, c_size_t initial_capacity,
c_HashMap_Hash_f hash, c_HashMap_Compare_f compare);
void c_HashSet_Destroy(c_HashSet_t* self);
c_err_t c_HashSet_Add(c_HashSet_t* self, const void* obj);
c_err_t c_HashSet_Remove(c_HashSet_t* self, const void* obj);
c_bool_t c_HashSet_Contains(c_HashSet_t* self, const void* obj);
c_size_t c_HashSet_GetSize(const c_HashSet_t* self);
// 集合迭代器巨集/函數重定向(完美保持一致性)
#define c_HashSetIter_Init(self, set) c_HashMapKeyIter_Init(self, &(set)->map)
#define c_HashSetIter_HasNext(self) c_HashMapKeyIter_HasNext(self)
#define c_HashSetIter_Get(self) c_HashMapKeyIter_Get(self)
#define c_HashSetIter_Next(self) c_HashMapKeyIter_Next(self)
#define c_HashSetIter_Remove(self) c_HashMapKeyIter_Remove(self)
#endif /*INCLUDED_C_HASHSET_H*/