Storage for uniquely defined items (and ordering criterion).
Class Set( ... ) from \ Sequence( ... )
... | An arbitrary list of parameters. |
The Set class implements a binary tree, uniquely and orderly storing a set of generic Falcon items. Instances of the Set class can be used as parameters for the Iterator constructor, and an iterator can be generated for them using first() and last() BOM methods. Also, instances of the Set class can be used as any other sequence in for/in loops.
Items in the set are ordered using the Falcon standard comparison algorithm; if they are instances of classes (or blessed dictionaries) implementing the compare() method, that method is used as a comparison criterion.
If the set constructor is given some parameters, it will be initially filled with those items; if some of them is duplicated, only one item will be then found in the set.
Methods | |
contains | Checks if a certain item is in the set. |
find | Checks if a certain item is in the set. |
insert | Adds an item to the set. |
len | Returns the number of items stored in this set. |
remove | Removes an item from a set. |
Methods inherited from class Sequence | |
append | Adds an item at the end of the sequence. |
back | Returns the last item in the Sequence. |
clear | Removes all the items from the Sequence. |
comp | Appends elements to this sequence through a filter. |
empty | Checks if the Sequence is empty or not. |
first | Returns an iterator to the first element of the Sequence. |
front | Returns the first item in the Sequence. |
last | Returns an iterator to the last element of the Sequence. |
mcomp | Appends elements to this sequence from multiple sources. |
mfcomp | Appends elements to this sequence from multiple sources through a filter. |
prepend | Adds an item in front of the sequence |
Checks if a certain item is in the set.
Set.contains( item )
item | The item to be found. |
Return | True if the item is in the set, false otherwise. |
Checks if a certain item is in the set.
Set.find( item )
item | The item to be found. |
Return | True if the item is in the set, false otherwise. |
Adds an item to the set.
Set.insert( item )
item | The item to be added. |
If an item considered equal to the added one exists, the previously set item is destroyed.
Returns the number of items stored in this set.
Set.len()
Return | Count of items in the set. |
Removes an item from a set.
Set.remove( item )
item | The item to be removed. |
Return | True if the item was removed, false if it wasn't found. |