神岛 API 文档 - ArenaPro版
    Preparing search index...

    Interface Set<T>

    Set 构造函数。

    Set constructor.

    interface Set<T> {
        "[toStringTag]": string;
        size: number;
        "[iterator]"(): SetIterator<T>;
        "[iterator]"(): IterableIterator<T>;
        add(value: T): this;
        add(value: T): this;
        clear(): void;
        delete(value: T): boolean;
        delete(value: T): boolean;
        entries(): SetIterator<[T, T]>;
        entries(): IterableIterator<[T, T]>;
        forEach(
            callbackfn: (value: T, value2: T, set: Set<T>) => void,
            thisArg?: any,
        ): void;
        forEach(
            callbackfn: (value: T, value2: T, set: Set<T>) => void,
            thisArg?: any,
        ): void;
        has(value: T): boolean;
        has(value: T): boolean;
        keys(): SetIterator<T>;
        keys(): IterableIterator<T>;
        values(): SetIterator<T>;
        values(): IterableIterator<T>;
    }

    Type Parameters

    • T
    Index

    Properties

    "[toStringTag]": string

    一个字符串值,用于创建对象的默认字符串描述。由内置方法 Object.prototype.toString 调用。

    A String value that is used in the creation of the default string description of an object. Called by the built-in method Object.prototype.toString.

    size: number

    the number of (unique) elements in Set.

    Methods

    • Iterates over values in the set.

      Returns SetIterator<T>

    • Returns IterableIterator<T>

      遍历集合中的值。

      Iterates over values in the set.

    • Appends a new element with a specified value to the end of the Set.

      Parameters

      • value: T

      Returns this

    • Parameters

      • value: T

      Returns this

      向 Set 对象添加一个新元素。

      Appends a new element with a specified value to the end of a Set object.

      要添加到 Set 对象的元素的值。

      The value of the element to add to the Set object.

      Set 对象。

      The Set object.

    • Returns void

      从 Set 对象中移除所有元素。

      Removes all elements from a Set object.

    • Removes a specified value from the Set.

      Parameters

      • value: T

      Returns boolean

      Returns true if an element in the Set existed and has been removed, or false if the element does not exist.

    • Parameters

      • value: T

      Returns boolean

      从 Set 对象中移除指定的元素。

      Removes the specified element from a Set object.

      要移除的元素的值。

      The value of the element to remove.

      如果元素成功移除,则返回 true;否则返回 false。

      Returns true if an element in the Set object existed and has been removed, or false if the element does not exist.

    • Returns an iterable of [v,v] pairs for every value v in the set.

      Returns SetIterator<[T, T]>

    • Returns IterableIterator<[T, T]>

      对于集合中的每个值 v,返回一个 [v,v] 对的可迭代对象。

      Returns an iterable of [v,v] pairs for every value v in the set.

    • Executes a provided function once per each value in the Set object, in insertion order.

      Parameters

      • callbackfn: (value: T, value2: T, set: Set<T>) => void
      • OptionalthisArg: any

      Returns void

    • Parameters

      • callbackfn: (value: T, value2: T, set: Set<T>) => void
      • OptionalthisArg: any

      Returns void

      对 Set 对象中的每个值执行一次提供的函数。

      Executes a provided function once for each value in the Set object.

      为每个元素执行的函数。

      Function to execute for each element.

      执行 callbackfn 时用作 this 的值。

      Value to use as this when executing callbackfn.

    • Parameters

      • value: T

      Returns boolean

      a boolean indicating whether an element with the specified value exists in the Set or not.

    • Parameters

      • value: T

      Returns boolean

      返回一个布尔值,指示具有指定值的元素是否存在。

      Returns a boolean indicating whether an element with the specified value exists or not.

      要在 Set 对象中测试其存在性的元素的值。

      The value of the element to test for presence in the Set object.

      如果具有指定值的元素存在于 Set 对象中,则返回 true;否则返回 false。

      Returns true if an element with the specified value exists in the Set object; otherwise false.

    • Despite its name, returns an iterable of the values in the set.

      Returns SetIterator<T>

    • Returns IterableIterator<T>

      尽管名称不同,但返回集合中值的可迭代对象。

      Despite its name, returns an iterable of the values in the set,

    • Returns an iterable of values in the set.

      Returns SetIterator<T>

    • Returns IterableIterator<T>

      返回集合中值的可迭代对象。

      Returns an iterable of values in the set.