Home > @silence_zhpf/utils > HashSet
HashSet 类是 TypeScript 中的一个通用类,它创建一个具有唯一元素的新集合。
Signature:
export declare class HashSet<T>
Property | Modifiers | Type | Description |
---|---|---|---|
size | readonly |
number | 获取HashSet 中的元素数量 |
Method | Modifiers | Description |
---|---|---|
add(v) | 该函数将值添加到 HashSet 并返回更新后的 HashSet . |
|
clear() | “clear”函数清除集合中的所有元素。 | |
difference(other) | 该函数返回一个新的 HashSet,其中包含当前 HashSet 但不在另一个 HashSet 中的元素。 | |
filter(fn) | 此函数根据给定条件过滤 HashSet 的元素,并返回包含过滤元素的新 HashSet。 | |
forEach(fn) | 此函数将给定函数应用于数组的每个元素。 | |
fromHashMap(map) | static |
此函数将 HashMap 转换为 TypeScript 中的 HashSet 。 |
fromHashMapValue(map) | static |
此函数将 HashMap 的值转换为 HashSet。 |
has(v) | 此函数检查集合中是否存在指定的值。 | |
intersection(other) | 该函数返回一个新的 HashSet,它包含当前 HashSet 和另一个 HashSet 的交集。 | |
isEmpty() | 该函数检查数据结构是否为空并返回布尔值。 | |
isEqual(other) | 此函数判断两个HashSet 是否相等 |
|
isSubset(other) | 此函数检查此 HashSet 是否是另一个 HashSet 的子集。 |
|
isSuperset(other) | 此函数检查此HashSet 是否是另一个HashSet 的超集。 |
|
map(fn) | 根据提供的函数将数组元素映射到新数组。 | |
new(array) | static |
使用可选的元素数组创建一个HashSet 对象 |
remove(v) | 此函数从 HashSet 中删除一个元素并返回更新后的 HashSet。 | |
symmetricDifference(other) | 此函数返回两个哈希集之间的对称差异。 | |
toHashMap() | ||
union(other) | 该函数返回一个新的 HashSet,它是当前 HashSet 和另一个 HashSet 的并集。 |