TreeSet¶
Note
TreeSet is essentially TreeMap with dummy values. So only constructor and methods summaries are provided here.
Contents
Constructor Summary¶
Constructor |
Description |
---|---|
|
Constructs a new, empty TreeSap. You can supply a
comparator if your elements do not implement rich
comparison methods (you do not need this for most
Python built-in objects).
|
Methods Summary¶
Method |
Description |
---|---|
|
Returns an iterator that iterates the elements
from the smallest to the largest.
|
|
Similar to
iterator() but the iterationgoes from the largest element to the smallest.
|
|
Returns a reverse order view of the elements.
|
|
Returns the number of elements in the set.
|
|
Returns
True if the set contains no element. |
|
Returns
True if this map contains thespecified element. Returns
False otherwise. |
|
Adds the specified element to the set if
it is not already present.
|
|
Removes the specified element if present
|
|
Removes all elements.
|
sub_map(from_element, to_element from_inclusive=True, to_inclusive=False) |
Returns a view of the portion of this set whose
elements range from from_element to to_element.
The default includes from_element but
excludes to_element.
|
|
Returns a view of the portion of this set whose
elements are less than (or equal to, if
inclusive is true) to_elemnt.
|
|
Returns a view of the portion of this set whose
elements are greater than (or equal to, if
inclusive is true) from_element.
|
|
Returns the comparator if you supplied one.
Returns
None otherwise. |
|
Returns the first/smallest/left-most element.
KeyError is raised if no such element exists. |
|
Returns the last/largest/right-most element.
KeyError is raised if no such element exists |
|
Returns the greatest element less than
the specified element.
Returns
None if no such element exists. |
|
Returns the greatest element
less than or equal to the specified element.
Returns
None if no such element exists. |
|
Returns the smallest element
greater than or equal to the specified element.
Returns
None if no such element exists. |
|
Returns the smallest element greater than
the specified element.
Returns
None if no such element exists. |
|
Removes and returns the first element.
Returns
None if no such element exists. |
|
Removes and returns the last element.
Returns
None if no such element exists. |