Storage for uniquely defined items (and ordering criterion).
class Set( ... ) \ from Sequence( ... )
init | Storage for uniquely defined items (and ordering criterion). |
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. |
append from Sequence | Adds an item at the end of the sequence. |
back from Sequence | Returns the last item in the Sequence. |
clear from Sequence | Removes all the items from the Sequence. |
comp from Sequence | Appends elements to this sequence through a filter. |
empty from Sequence | Checks if the Sequence is empty or not. |
first from Sequence | Returns an iterator to the first element of the Sequence. |
front from Sequence | Returns the first item in the Sequence. |
last from Sequence | Returns an iterator to the last element of the Sequence. |
prepend from Sequence | Adds an item in front of the sequence |
Storage for uniquely defined items (and ordering criterion).
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.
Storage for uniquely defined items (and ordering criterion).
init Set( ... )
... | 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.
Checks if a certain item is in the set.
Set.contains( item )
item | The item to be found. |
Returns: | 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. |
Returns: | 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( )
Returns: | Count of items in the set. |
Removes an item from a set.
Set.remove( item )
item | The item to be removed. |
Returns: | True if the item was removed, false if it wasn't found. |