View source

abstract thx.HashSet<T>(HashMap<T, Bool>)

Available on all platforms

A set is a list of unique, hashable values. Equality of items is determined using a required function hashCode():Int on the item instances.

Class Fields

function create<T>(?arr:Iterable<T>):HashSet<T>

Creates a new HashSet with optional intial values.

Instance Fields

var length(get,null):Int

Gives the number of items in the HashSet

function add(v:T):Bool

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

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

function copy():HashSet<T>

copy creates a new HashSet with copied elements.

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

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

function empty():HashSet<T>

empty creates an empty copy of the current HashSet.

inline function exists(v:T):Bool

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

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

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

function iterator():Iterator<T>

Iterates the values of the HashSet.

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

inline function remove(v:T):Bool

remove removes an item from the HashSet.

inline function symmetricDifference(set:HashSet<T>):HashSet<T>

symmetricDifference creates a new HashSet with elements that appear in either of the sets, but not in both.

Equivalent to: s1.union(s2) - s1.intersection(s2)

function toArray():Array<T>

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

function toString():String

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

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

Union creates a new HashSet with elements from both sets.