A type of Set
that has the additional guarantee that the iteration order of values will be the order in which they were added.
type OrderedSet<T> extends Set<T>, OrderedCollection<T>
The iteration behavior of OrderedSet is the same as native ES6 Set.
Note that OrderedSet
are more expensive than non-ordered Set and may consume more memory. OrderedSet#add
is amortized O(log32 N)
, but not stable.
Set
OrderedSet
has the exact same API as Set
. The only new method is OrderedSet.isOrderedSet(maybeOrderedSet)
to check if a value is an OrderedSet
.
Create a new immutable OrderedSet containing the values of the provided collection-like.
OrderedSet<T>(collection?: Iterable<T> | ArrayLike<T>): OrderedSet<T>
Note: OrderedSet
is a factory function and not a class, and does not use the new
keyword during construction.
True if the provided value is an OrderedSet.
OrderedSet.isOrderedSet(maybeOrderedSet): boolean