Set type (joe)


A Joe Set is a Java Set, roughly equivalent to a Java HashSet. Sets created using the Set() initializer can contain any kind of Joe value; the set need not be homogeneous. Sets received from Java code might be read-only or require a specific value type.

Initializer

Methods

Set Initializer


Set(values...) → Set

Creates a Set of the argument values, which must be a flat list of key/value pairs.

Methods


set.add()


set.add(value) → Boolean

Adds the value to the set, returning true if it wasn't already present.

set.addAll()


set.addAll(collection) → Boolean

Adds the content of the collection to this set.

set.clear()


set.clear() → this

Empties the set.

set.contains()


set.contains(value) → Boolean

Returns true if the set contains the value, and false otherwise.

set.copy()


set.copy() → Set

Returns a shallow copy of this set.

set.filter()


set.filter(predicate) → Set

Returns a list containing the elements for which the filter predicate is true.

set.isEmpty()


set.isEmpty() → Boolean

Returns true if the set is empty, and false otherwise.

set.map()


set.map(func) → Set

Returns a set containing the items that result from applying function func to each item in this set.

set.remove()


set.remove(value) → Boolean

Removes the value, return true if it was present and false otherwise.

set.removeAll()


set.removeAll(collection) → Boolean

Removes all values in the collection from the set, returning true if the set changed and false otherwise.

set.size()


set.size() → Number

Returns the number of values in the set.

set.sorted()


set.sorted([comparator]) → List

Returns a list of the set's items, sorted in ascending order. If no comparator is provided, then this set must be a set of strings or numbers. If a comparator is given, it must be a function that takes two arguments and returns -1, 0, 1, like the standard Joe.compare() function.

To sort in descending order, provide a comparator that reverses the comparison.

set.toString()


set.toString() → String

Returns the set's string representation.