def __init__(self, iterable=None, key=None):
        """
        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.
        """
        self._key = key

        if not hasattr(self, '_set'):
            self._set = set()

        _set = self._set
        self.isdisjoint = _set.isdisjoint
        self.issubset = _set.issubset
        self.issuperset = _set.issuperset

        if key is None:
            self._list = SortedList(self._set)
        else:
            self._list = SortedListWithKey(self._set, key=key)

        _list = self._list
        self.bisect_left = _list.bisect_left
        self.bisect = _list.bisect
        self.bisect_right = _list.bisect_right
        self.index = _list.index
        self.irange = _list.irange
        self.islice = _list.islice
        self._reset = _list._reset  # pylint: disable=protected-access

        if key is not None:
            self.bisect_key_left = _list.bisect_key_left
            self.bisect_key_right = _list.bisect_key_right
            self.bisect_key = _list.bisect_key
            self.irange_key = _list.irange_key

        if iterable is not None:
            self._update(iterable)
def __init__ ( self , iterable = None , key = None ) : self . _key = key if not hasattr ( self , '_set' ) : self . _set = set ( ) _set = self . _set self . isdisjoint = _set . isdisjoint self . issubset = _set . issubset self . issuperset = _set . issuperset if key is None : self . _list = SortedList ( self . _set ) else : self . _list = SortedListWithKey ( self . _set , key = key ) _list = self . _list self . bisect_left = _list . bisect_left self . bisect = _list . bisect self . bisect_right = _list . bisect_right self . index = _list . index self . irange = _list . irange self . islice = _list . islice self . _reset = _list . _reset if key is not None : self . bisect_key_left = _list . bisect_key_left self . bisect_key_right = _list . bisect_key_right self . bisect_key = _list . bisect_key self . irange_key = _list . irange_key if iterable is not None : self . _update ( iterable )
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.