View source

abstract thx.Set<T>(Map<T, Bool>)

Available on all platforms

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.

Class Fields

function createEnum(?arr:Iterable<EnumValue>):Set<EnumValue>

Creates a Set of EnumValue, with optional initial values.

function createInt(?it:Iterable<Int>):Set<Int>

Creates a Set of Ints with optional initial values.

function createObject(?it:Iterable<{}>):Set<{}>

Creates a Set of anonymous objects with optional initial values.

function createString(?it:Iterable<String>):Set<String>

Creates a Set of Strings with optional initial values.

Instance Fields

var length(get,null):Int

function 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.

function copy():Set<T>

copy creates a new Set with copied elements.

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

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

function empty():Set<T>

Creates an empty copy of the current set.

inline function exists(v:T):Bool

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

function filter(predicate:T -> Bool):Set<T>

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

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

function iterator():Iterator<T>

Iterates the values of the Set.

function map<TOut>(f:T -> TOut):Array<TOut>

inline function push(v:T):Void

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

function pushMany(values:Iterable<T>):Void

Pushes many values to the set

function reduce<TOut>(handler:TOut -> T -> TOut, acc:TOut):TOut

inline function remove(v:T):Bool

function 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.

function toString():String

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

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

Union creates a new Set with elements from both sets.