Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ObjectSet<T>

Type parameters

  • T

Hierarchy

Implements

  • Set<T>

Index

Constructors

constructor

  • new ObjectSet(iterable?: Iterable<T>): ObjectSet
  • Creates a new ObjectSet and optionally seeds it with values.

    Parameters

    • Optional iterable: Iterable<T>

      An optional iterable of values to add to the set.

    Returns ObjectSet

Properties

__@toStringTag

__@toStringTag: "Set" = "Set"

Returns the string literal 'Set' for use by Object.prototype.toString. This allows for identifying Sets without checking constructor identity.

Protected _values

_values: Array<T> = []

Accessors

size

  • get size(): number
  • Returns the number of members in the set.

    Returns number

Methods

__@iterator

  • __@iterator(): IterableIterator<T>
  • Returns an IterableIterator of each member of the set.

    Returns IterableIterator<T>

add

  • add(value: T): this
  • Add a value to the set. If the value is already contained in the set, it will not be added a second time.

    Parameters

    • value: T

      The value to add

    Returns this

clear

  • clear(): void

Abstract delete

  • delete(value: T): boolean
  • Removes a particular value from the set. If the value was contained in the set prior to this method being called, true will be returned; if the value was not in the set, false will be returned. In either case, the value provided will not be in the set after this method returns.

    Parameters

    • value: T

      The value to remove from the set.

    Returns boolean

entries

  • entries(): IterableIterator<[T, T]>
  • Returns an iterable two-member tuples for each item in the set, where the item is provided twice.

    Part of the ES2015 Set specification for compatibility with Map objects.

    Returns IterableIterator<[T, T]>

forEach

  • forEach(callback: function, thisArg?: any): void
  • Invokes a callback once for each member of the set.

    Parameters

    • callback: function

      The function to invoke with each set member

        • (value: T, value2: T, set: Set<T>): void
        • Parameters

          • value: T
          • value2: T
          • set: Set<T>

          Returns void

    • Optional thisArg: any

      The this context on which to invoke the callback

    Returns void

Abstract has

  • has(value: T): boolean
  • Determines if a provided value is already a member of the set.

    Parameters

    • value: T

      The value against which set members should be checked

    Returns boolean

keys

  • keys(): IterableIterator<T>
  • Returns an IterableIterator of each member of the set.

    Returns IterableIterator<T>

values

  • values(): IterableIterator<T>
  • Returns an IterableIterator of each member of the set.

    Returns IterableIterator<T>