Set<T>

Unordered collection of unique elements.

Type Constraints: T Constrains Hashable

xxml
Language::Collections

Methods

MethodParametersReturnsDescription
ConstructorSet<T>^Create empty set
addelement: T^Bool^Add element (false if exists)
removeelement: T^Bool^Remove element
containselement: T^Bool^Check membership
sizeInteger^Element count
isEmptyBool^Check if empty
clearNoneRemove all elements
unionother: Set<T>^Set<T>^Set union
intersectionother: Set<T>^Set<T>^Set intersection
differenceother: Set<T>^Set<T>^Set difference
beginSetIterator<T>^Get iterator

Examples

Set Operations

xxml
Instantiate Collections::Set<String>^ As <tags> = Collections::Set@String::Constructor();
Run tags.add(String::Constructor("xxml"));
Run tags.add(String::Constructor("programming"));
Run tags.add(String::Constructor("xxml"));  // Returns false, already exists

Instantiate Integer^ As <count> = tags.size();  // 2

See Also