A set is a list of unique values. Value equality is determined using ==.

See thx.HashSet for an alternative set implementation that uses a hash code to determine item equality.

Variables

read onlylength:Int

Methods

add (v:T):Bool

add pushes a value into Set if the value was not already present.

It returns a boolean value indicating if Set was changed by the operation or not.

copy ():Set<T>

copy creates a new Set with copied elements.

inline difference (set:Set<T>):Set<T>

difference creates a new Set with elements from the first set excluding the elements from the second.

empty ():Set<T>

Creates an empty copy of the current set.

inline exists (v:T):Bool

exists returns true if it contains an element that is equals to v.

filter (predicate:T ‑> Bool):Set<T>

inline intersection (set:Set<T>):Set<T>

intersection returns a Set with elements that are presents in both sets

iterator ():Iterator<T>

Iterates the values of the Set.

map<TOut> (f:T ‑> TOut):Array<TOut>

inline push (v:T):Void

Like add but doesn't notify if the addition was successful or not.

pushMany (values:Iterable<T>):Void

Pushes many values to the set

reduce<TOut> (handler:TOut ‑> T ‑> TOut, acc:TOut):TOut

inline remove (v:T):Bool

toArray ():Array<T>

Converts a Set<T> into Array<T>. The returned array is a copy of the internal array used by Set. This ensures that the set is not affected by unsafe operations that might happen on the returned array.

toString ():String

Converts Set into String. To differentiate from normal Arrays the output string uses curly braces {} instead of square brackets [].

inline union (set:Set<T>):Set<T>

Union creates a new Set with elements from both sets.

Static methods

staticcreateEnum<T> (?arr:Iterable<T>):Set<T>

Creates a Set of EnumValue, with optional initial values.

staticcreateInt (?it:Iterable<Int>):Set<Int>

Creates a Set of Ints with optional initial values.

staticcreateObject<T> (?it:Iterable<T>):Set<T>

Creates a Set of anonymous objects with optional initial values.

staticcreateString (?it:Iterable<String>):Set<String>

Creates a Set of Strings with optional initial values.