Class Set

An unordered iterable collection that cannot contain two instances of the same kind of value. It optionally enforces the type of elements that may be added to the Set.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(type: new(...args: any[]) => Object): Set

This creates a Set that checks the type of the values.

Parameters

  • type: new(...args: any[]) => Object

    this must be a class function/constructor.

Returns

Set

constructor(type?: string): Set

This creates a Set that may check the types of the values.

Parameters

  • type?: string optional

    if supplied, this must be one of: 'number' or 'string' for the key type.

Returns

Set

Properties

public count: number

Gets the number of elements in the Set.

public iterator: Iterator

Gets an object that you can use for iterating over the Set.

Methods

public add(val: any): boolean

Adds a given value to the Set, if not already present.

Parameters

  • val: any

Returns

boolean

public addAll(coll: any): Set

Adds all of the values of a collection (either an Iterable or an Array) to this Set.

Parameters

  • coll: any

Returns

Set

public clear(): any

Clears the Set.

Returns

any

public contains(val: any): boolean

Returns whether the given value is in this Set.

Parameters

  • val: any

Returns

boolean

public containsAll(coll: Iterable): boolean

Returns true if all of the values of a given collection are in this Set.

Parameters

Returns

boolean

public containsAny(coll: Iterable): boolean

Returns true if any of the values of a given collection are in this Set.

Parameters

Returns

boolean

public copy(): Set

Makes a shallow copy of this Set.

Returns

Set

public first(): any

Returns the first item in the collection, or null if there is none.

Returns

any

public remove(val: any): boolean

Removes a value (if found) from the Set.

Parameters

  • val: any

Returns

boolean

public removeAll(coll: Iterable): Set

Removes all of the values of a collection from this Set.

Parameters

Returns

Set

public retainAll(coll: Iterable): Set

Removes from this Set all items that are not in the given collection.

Parameters

Returns

Set

public toArray(): Array<any>

Produces a JavaScript Array from the contents of this Set.

Returns

Array<any>

public toList(): List

Converts the Set to a List.

Returns

List