Cloud Software Group, Inc. EBX®
Documentation > Developer Guide > EBX® Script > API
Navigation modeDocumentation > Developer Guide > EBX® Script > API

Unit core.set

Script unit that provides methods to create and manipulate sets.

Methods

function add(set: set<ItemType>, element: ItemType): boolean

Adds the specified element to the set if it is not already present.

function addAll(set: set<ItemType>, elements: collection<ItemType>): boolean

Adds all elements from the specified collection to the set.

procedure clear(set: set<ItemType>)

Removes all elements from the set.

function clone(set: set<ItemType>): set<ItemType>

Returns a shallow clone of the set.

function contains(set: set<ItemType>, element: ItemType): boolean

Returns true if set contains the specified element.

function containsAll(set: set<ItemType>, elements: collection<ItemType>): boolean

Returns true if set contains all elements of the specified collection.

function difference(set1: set<ItemType>, set2: set<ItemType>): set<ItemType>

Returns a new set containing elements that are in the first set but not in the second (difference).

function equals(set1: set<ItemType>, set2: set<ItemType>): boolean

Compares two sets for equality.

function fromList(list: list<ItemType>): set<ItemType>

Converts a list to a set containing the same elements, preserving order of first occurrence.

function intersection(set1: set<ItemType>, set2: set<ItemType>): set<ItemType>

Returns a new set containing only elements that are present in both sets (intersection).

function isEmpty(value: set): boolean

Returns true if value is null or an empty set.

function of(value: ItemType [, value: ItemType]...): set

Creates a set with the elements passed as parameters.

function remove(set: set<ItemType>, element: ItemType): boolean

Removes the specified element from the set if it is present.

function removeAll(set: set<ItemType>, elements: collection<ItemType>): boolean

Removes from the set all of its elements that are contained in the specified collection.

function retainAll(set: set<ItemType>, elements: collection<ItemType>): boolean

Retains only the elements in the set that are contained in the specified collection.

function size(set: set<ItemType>): integer

Returns the number of elements in the set.

function toList(set: set<ItemType>): list<ItemType>

Converts a set to a list containing the same elements, preserving order.

function union(set1: set<ItemType>, set2: set<ItemType>): set<ItemType>

Returns a new set containing all elements from both sets (union).

add

function add(set: set<ItemType>, element: ItemType): boolean

Adds the specified element to the set if it is not already present.

Parameters :

set: the set to which the element is to be added.

element: the element to be added to the set.

Return :

true if the set did not already contain the specified element.

Can be used in: 

addAll

function addAll(set: set<ItemType>, elements: collection<ItemType>): boolean

Adds all elements from the specified collection to the set.

Parameters :

set: the set to which elements are to be added.

elements: collection containing elements to be added to the set.

Return :

true if the set was modified as a result of the call.

Can be used in: 

clear

procedure clear(set: set<ItemType>)

Removes all elements from the set.

Parameters :

set: the set to be cleared.

Can be used in: 

clone

function clone(set: set<ItemType>): set<ItemType>

Returns a shallow clone of the set.

Parameters :

set: the set to clone.

Return :

a new set with the same elements as the input set.

Can be used in: 

contains

function contains(set: set<ItemType>, element: ItemType): boolean

Returns true if set contains the specified element.

Parameters :

set: the input set.

element: the element whose presence in the set is to be tested.

Return :

true if the set contains the specified element, false otherwise. Returns null if set is null.

Can be used in: 

containsAll

function containsAll(set: set<ItemType>, elements: collection<ItemType>): boolean

Returns true if set contains all elements of the specified collection.

Parameters :

set: the input set.

elements: collection to be checked for containment in the set.

Return :

true if the set contains all elements of the specified collection, false otherwise. Returns null if any parameter is null.

Can be used in: 

difference

function difference(set1: set<ItemType>, set2: set<ItemType>): set<ItemType>

Returns a new set containing elements that are in the first set but not in the second (difference).

Parameters :

set1: the set from which elements are to be removed.

set2: the set containing elements to be removed from set1.

Return :

a new set containing elements in set1 but not in set2. Returns an empty set if set1 is null.

Can be used in: 

equals

function equals(set1: set<ItemType>, set2: set<ItemType>): boolean

Compares two sets for equality.

Parameters :

set1: the first set.

set2: the second set.

Return :

true if both sets contain the same elements, false otherwise.

Can be used in: 

fromList

function fromList(list: list<ItemType>): set<ItemType>

Converts a list to a set containing the same elements, preserving order of first occurrence.

Parameters :

list: the input list.

Return :

a set containing the unique elements of the list, in order of first occurrence.

Can be used in: 

intersection

function intersection(set1: set<ItemType>, set2: set<ItemType>): set<ItemType>

Returns a new set containing only elements that are present in both sets (intersection).

Parameters :

set1: the first set.

set2: the second set.

Return :

a new set containing only elements present in both sets. Returns an empty set if any parameter is null.

Can be used in: 

isEmpty

function isEmpty(value: set): boolean

Returns true if value is null or an empty set.

Parameters :

value: an input set.

Return :

true if value is null or an empty set, or else false.

Can be used in: 

of

function of(value: ItemType [, value: ItemType]...): set

Creates a set with the elements passed as parameters. All elements must be of same type.

Parameters :

value: items to add to the set. All items must be of same type.

Return :

the new set. It is updatable.

Can be used in: 

remove

function remove(set: set<ItemType>, element: ItemType): boolean

Removes the specified element from the set if it is present.

Parameters :

set: the set from which the element is to be removed.

element: the element to be removed from the set, if present.

Return :

true if the set contained the specified element.

Can be used in: 

removeAll

function removeAll(set: set<ItemType>, elements: collection<ItemType>): boolean

Removes from the set all of its elements that are contained in the specified collection.

Parameters :

set: the set from which elements are to be removed.

elements: collection containing elements to be removed from the set.

Return :

true if the set was modified as a result of the call.

Can be used in: 

retainAll

function retainAll(set: set<ItemType>, elements: collection<ItemType>): boolean

Retains only the elements in the set that are contained in the specified collection.

Parameters :

set: the set to modify.

elements: collection containing elements to be retained in the set.

Return :

true if the set was modified as a result of the call.

Can be used in: 

size

function size(set: set<ItemType>): integer

Returns the number of elements in the set.

Parameters :

set: the input set.

Return :

the number of elements in the set, or 0 if the set is null.

Can be used in: 

toList

function toList(set: set<ItemType>): list<ItemType>

Converts a set to a list containing the same elements, preserving order.

Parameters :

set: the input set.

Return :

a list containing the elements of the set, in iteration order.

Can be used in: 

union

function union(set1: set<ItemType>, set2: set<ItemType>): set<ItemType>

Returns a new set containing all elements from both sets (union).

Parameters :

set1: the first set.

set2: the second set.

Return :

a new set containing all elements from both sets. Returns an empty set if both parameters are null.

Can be used in: 

Documentation > Developer Guide > EBX® Script > API