ANTAREX API

Clava API

LARA API

LARA Common Language API

(.js)
laraImport("lara.util.StringSet");

(.lara)
import lara.util.StringSet;

StringSet

Constructor

StringSet

new StringSet([args = []])

Based on this code: https://stackoverflow.com/questions/4343746/is-there-a-data-structure-like-the-java-set-in-javascript

Changed the name of functions 'contains' to the name used in ECMAScript 6 ('has').
'remove' has not been changed to 'delete' because in LARA 'delete' is a keyword and cannot be used as a function name
Also, tweaked the functionality of 'add' and 'delete' to behave similarly to ECMAScript 6 Set.

Parameters

args: Object... - Objects that will be transformed to Strings and used as the initial values of the set. (optional)

Static Members

difference

difference(setA, setB)

Parameters

setA: StringSet
setB: StringSet

Returns

StringSet - A new set with the difference of sets A and B, i.e. `A - B`. Note that is different from `B - A`.

intersection

intersection(setA, setB)

Parameters

setA: StringSet
setB: StringSet

Returns

StringSet - A new set with the insersection of sets A and B

isStringSet

isStringSet(s)

Parameters

s: StringSet

Returns

Boolean - True, if `s` is an instance of StringSet

union

union(setA, setB)

Parameters

setA: StringSet
setB: StringSet

Returns

StringSet - A new set with the union of sets A and B

Instance Members

_Symbol$iterator

_Symbol$iterator()

Implement the generator. StringSet can be used e.g. in `for...of`


add

add(str)

Add an element to the set

Parameters

str: String - Element to be added

Returns

any - The element `str` itself

constructor

constructor(...args)

Parameters

...args: unknown

copy

copy()

Returns

StringSet - A new copy of the set

difference

difference(otherSet)

Stores in this set the difference of it with another another set (i.e.
`this - otherSet`). Notice that is not equivalent to `otherSet - this`.

Parameters

otherSet: StringSet

Returns

this

has

has(str)

Check if element exists in the set

Parameters

str: String - Element to be checked

Returns

any - True if exists, false otherwise

intersection

intersection(otherSet)

Stores in this set the intersection of it with another another set

Parameters

otherSet: StringSet

Returns

this

isEmpty

isEmpty()

Returns

Boolean - True if the set is empty, false otherwise

remove

remove(str)

Remove an element from the set if it exists

Parameters

str: String - Element to be removed

Returns

Boolean - True if the element `str` existed and was removed, false otherwise

toString

toString()

Returns

String - A comma seperated list of the values in this set, delimited by brackets to denote a set like data-structure

union

union(otherSet)

Stores in this set the union of it with another another set

Parameters

otherSet: StringSet

Returns

this

values

values()

Returns

String[] - A list of the elements in the set