UniqueSet¶
A UniqueSet
is a collection of any type in kOS. It doesn’t store items in any particular order and does not allow duplicate items.
You can read more about sets on Wikipedia.
Usage example:
SET S TO UNIQUESET(1,2,3).
PRINT S:LENGTH. // will print 3
S:ADD(1). // 1 was already in the set so nothing happens
PRINT S:LENGTH. // will print 3 again
Structure¶
- structure UniqueSet¶
Suffix
Type
Description
All suffixes of
Enumerable
UniqueSet
objects are a type ofEnumerable
None
append an item
None
remove item
None
remove all elements
a new copy of this set
Note
This type is serializable.
- UniqueSet:ADD(item)¶
- Parameters
item – (any type) item to be added
Appends the new value given.
- UniqueSet:REMOVE(item)¶
- Parameters
item – (any type) item to be removed
Remove the item from the set.
- UniqueSet:CLEAR()¶
- Returns
none
Calling this suffix will remove all of the items currently stored in the set.