Indexable Set Recipe¶
-
class
sortedcollections.
IndexableSet
(*args, **kwargs)¶ Set that supports numerical indexing.
For example:
>>> indexable_set = IndexableSet('abcde') >>> list(indexable_set) ['d', 'e', 'c', 'b', 'a'] >>> indexable_set[0] 'd' >>> indexable_set[-2:] ['b', 'a']
IndexableSet implements the collections.Sequence interface.
-
__init__
(*args, **kwargs)¶ A SortedSet provides the same methods as a set. Additionally, a SortedSet maintains its items in sorted order, allowing the SortedSet to be indexed.
An optional iterable provides an initial series of items to populate the SortedSet.
An optional key argument defines a callable that, like the key argument to Python’s sorted function, extracts a comparison key from each set item. If no function is specified, the default compares the set items directly.
-