View source

abstract thx.OrderedSet<T>(Array<T>)

Available on all platforms

A set is a list of unique values.

Class Fields

function arrayToOrderedSet<T>(arr:Array<T>):OrderedSet<T>

function create<T>(?arr:Array<T>):OrderedSet<T>

Creates an empty OrderedSet if no argument is provided or it fallsback to arrayToOrderedSet otherwise.

function toOrderedSet<T>(arr:Array<T>):OrderedSet<T>

arrayToOrderedSet converts an Array into a OrderedSet removing all duplicated values.

Instance Fields

function add(v:T):Bool

add pushes a value onto the end of the OrderedSet if the value was not already present.

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

inline function copy():OrderedSet<T>

copy creates a new OrderedSet with copied elements.

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

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

function exists(v:T):Bool

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

inline function get(index:Int):Null<T>

get returns the element at the specified position or null if the index is outside the boundaries.

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

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

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 setToArray():Array<T>

inline function slice(pos:Int, ?end:Int):OrderedSet<T>

Same operations as Array.slice() but it returns a new OrderedSet instead of an array.

inline function splice(pos:Int, len:Int):OrderedSet<T>

Same operations as Array.splice() but it returns a new OrderedSet instead of an array.

function toArray():Array<T>

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

function toString():String

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

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

Union creates a new OrderedSet with elements from both sets.

inline function unionArray(set:Array<T>):OrderedSet<T>

Union creates a new OrderedSet with elements from both sets.