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
ADD(item)
None append an item REMOVE(item)
None remove item CLEAR()
None remove all elements COPY
UniqueSet
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.