# Set
一组唯一的通用值。
¥A set of unique generic values.
Set API 与 JavaScript (MDN (opens new window)) 非常相似,但迭代器尚未实现。
¥The Set API is very similar to JavaScript's (MDN (opens new window)), but iterators are not implemented yet.
# 构造函数
¥Constructor
- new Set<T>()- 构造一组新的 - T类型的唯一值。- ¥Constructs a new set of unique value of type - T.
# 实例成员
¥Instance members
# 字段
¥Fields
- readonly size: i32- 集合中当前唯一值的数量。 - ¥The current number of unique values in the set. 
# 方法
¥Methods
- function add(value: T): void- 将指定值添加到集合中。如果该值已经存在,则不执行任何操作。 - ¥Adds the specified value to the set. Does nothing if the value already exists. 
- function delete(value: T): bool- 删除指定的值。如果找到该值,则返回 - true,否则返回- false。- ¥Deletes the specified value. Returns - trueif the value was found, otherwise- false.
- function clear(): void- 清除集合,删除所有值。 - ¥Clears the set, deleting all values. 
- function has(value: T): bool- 测试指定的值是否存在于集合中。 - ¥Tests if the specified value exists in the set. 
- function values(): Array<T>- 按插入顺序获取此集合中包含的值作为数组。这是初步的,但不支持迭代器。 - ¥Gets the values contained in this set as an array, in insertion order. This is preliminary while iterators are not supported. 
- function toString(): string- 返回该集合的字符串表示形式。 - ¥Returns a string representation of this set. 
← process StaticArray →