class_docstr: Sorted set is a sorted mutable set.
  
  Sorted set values are maintained in sorted order. The design of sorted set
  is simple: sorted set uses a set for set-operations and maintains a sorted
  list of values.
  
  Sorted set values must be hashable and comparable. The hash and total
  ordering of values must not change while they are stored in the sorted set.
  
  Mutable set methods:
  
  * :func:`SortedSet.__contains__`
  * :func:`SortedSet.__iter__`
  * :func:`SortedSet.__len__`
  * :func:`SortedSet.add`
  * :func:`SortedSet.discard`
  
  Sequence methods:
  
  * :func:`SortedSet.__getitem__`
  * :func:`SortedSet.__delitem__`
  * :func:`SortedSet.__reversed__`
  
  Methods for removing values:
  
  * :func:`SortedSet.clear`
  * :func:`SortedSet.pop`
  * :func:`SortedSet.remove`
  
  Set-operation methods:
  
  * :func:`SortedSet.difference`
  * :func:`SortedSet.difference_update`
  * :func:`SortedSet.intersection`
  * :func:`SortedSet.intersection_update`
  * :func:`SortedSet.symmetric_difference`
  * :func:`SortedSet.symmetric_difference_update`
  * :func:`SortedSet.union`
  * :func:`SortedSet.update`
  
  Methods for miscellany:
  
  * :func:`SortedSet.copy`
  * :func:`SortedSet.count`
  * :func:`SortedSet.__repr__`
  * :func:`SortedSet._check`
  
  Sorted list methods available:
  
  * :func:`SortedList.bisect_left`
  * :func:`SortedList.bisect_right`
  * :func:`SortedList.index`
  * :func:`SortedList.irange`
  * :func:`SortedList.islice`
  * :func:`SortedList._reset`
  
  Additional sorted list methods available, if key-function used:
  
  * :func:`SortedKeyList.bisect_key_left`
  * :func:`SortedKeyList.bisect_key_right`
  * :func:`SortedKeyList.irange_key`
  
  Sorted set comparisons use subset and superset relations. Two sorted sets
  are equal if and only if every element of each sorted set is contained in
  the other (each is a subset of the other). A sorted set is less than
  another sorted set if and only if the first sorted set is a proper subset
  of the second sorted set (is a subset, but is not equal). A sorted set is
  greater than another sorted set if and only if the first sorted set is a
  proper superset of the second sorted set (is a superset, but is not equal).
class_docstr_tok: ["Sorted","set","is","a","sorted","mutable","set",".","Sorted","set","values","are","maintained","in","sorted","order",".","The","design","of","sorted","set","is","simple",":","sorted","set","uses","a","set","for","set-operations","and","maintains","a","sorted","list","of","values",".","Sorted","set","values","must","be","hashable","and","comparable",".","The","hash","and","total","ordering","of","values","must","not","change","while","they","are","stored","in","the","sorted","set",".","Mutable","set","methods",":","*",":","func",":","`","SortedSet.__contains__","`","*",":","func",":","`","SortedSet.__iter__","`","*",":","func",":","`","SortedSet.__len__","`","*",":","func",":","`","SortedSet.add","`","*",":","func",":","`","SortedSet.discard","`","Sequence","methods",":","*",":","func",":","`","SortedSet.__getitem__","`","*",":","func",":","`","SortedSet.__delitem__","`","*",":","func",":","`","SortedSet.__reversed__","`","Methods","for","removing","values",":","*",":","func",":","`","SortedSet.clear","`","*",":","func",":","`","SortedSet.pop","`","*",":","func",":","`","SortedSet.remove","`","Set-operation","methods",":","*",":","func",":","`","SortedSet.difference","`","*",":","func",":","`","SortedSet.difference_update","`","*",":","func",":","`","SortedSet.intersection","`","*",":","func",":","`","SortedSet.intersection_update","`","*",":","func",":","`","SortedSet.symmetric_difference","`","*",":","func",":","`","SortedSet.symmetric_difference_update","`","*",":","func",":","`","SortedSet.union","`","*",":","func",":","`","SortedSet.update","`","Methods","for","miscellany",":","*",":","func",":","`","SortedSet.copy","`","*",":","func",":","`","SortedSet.count","`","*",":","func",":","`","SortedSet.__repr__","`","*",":","func",":","`","SortedSet._check","`","Sorted","list","methods","available",":","*",":","func",":","`","SortedList.bisect_left","`","*",":","func",":","`","SortedList.bisect_right","`","*",":","func",":","`","SortedList.index","`","*",":","func",":","`","SortedList.irange","`","*",":","func",":","`","SortedList.islice","`","*",":","func",":","`","SortedList._reset","`","Additional","sorted","list","methods","available",",","if","key-function","used",":","*",":","func",":","`","SortedKeyList.bisect_key_left","`","*",":","func",":","`","SortedKeyList.bisect_key_right","`","*",":","func",":","`","SortedKeyList.irange_key","`","Sorted","set","comparisons","use","subset","and","superset","relations",".","Two","sorted","sets","are","equal","if","and","only","if","every","element","of","each","sorted","set","is","contained","in","the","other","(","each","is","a","subset","of","the","other",")",".","A","sorted","set","is","less","than","another","sorted","set","if","and","only","if","the","first","sorted","set","is","a","proper","subset","of","the","second","sorted","set","(","is","a","subset",",","but","is","not","equal",")",".","A","sorted","set","is","greater","than","another","sorted","set","if","and","only","if","the","first","sorted","set","is","a","proper","superset","of","the","second","sorted","set","(","is","a","superset",",","but","is","not","equal",")","."]
docstr: Initialize sorted set instance.
  
  Optional `iterable` argument provides an initial iterable of values to
  initialize the sorted set.
  
  Optional `key` argument defines a callable that, like the `key`
  argument to Python's `sorted` function, extracts a comparison key from
  each value. The default, none, compares values directly.
  
  Runtime complexity: `O(n*log(n))`
  
  >>> ss = SortedSet([3, 1, 2, 5, 4])
  >>> ss
  SortedSet([1, 2, 3, 4, 5])
  >>> from operator import neg
  >>> ss = SortedSet([3, 1, 2, 5, 4], neg)
  >>> ss
  SortedSet([5, 4, 3, 2, 1], key=<built-in function neg>)
  
  :param iterable: initial values (optional)
  :param key: function used to extract comparison key (optional)
docstr_tok: ["Initialize","sorted","set","instance",".","Optional","`","iterable","`","argument","provides","an","initial","iterable","of","values","to","initialize","the","sorted","set",".","Optional","`","key","`","argument","defines","a","callable","that",",","like","the","`","key","`","argument","to","Python","'s","`","sorted","`","function",",","extracts","a","comparison","key","from","each","value",".","The","default",",","none",",","compares","values","directly",".","Runtime","complexity",":","`","O","(","n","*","log","(","n",")",")","`",">",">",">","ss","=","SortedSet","(","[","3",",","1",",","2",",","5",",","4","]",")",">",">",">","ss","SortedSet","(","[","1",",","2",",","3",",","4",",","5","]",")",">",">",">","from","operator","import","neg",">",">",">","ss","=","SortedSet","(","[","3",",","1",",","2",",","5",",","4","]",",","neg",")",">",">",">","ss","SortedSet","(","[","5",",","4",",","3",",","2",",","1","]",",","key=","<","built-in","function","neg",">",")",":","param","iterable",":","initial","values","(","optional",")",":","param","key",":","function","used","to","extract","comparison","key","(","optional",")"]
code: def __init__(self, iterable=None, key=None):
      """Initialize sorted set instance.
  
      Optional `iterable` argument provides an initial iterable of values to
      initialize the sorted set.
  
      Optional `key` argument defines a callable that, like the `key`
      argument to Python's `sorted` function, extracts a comparison key from
      each value. The default, none, compares values directly.
  
      Runtime complexity: `O(n*log(n))`
  
      >>> ss = SortedSet([3, 1, 2, 5, 4])
      >>> ss
      SortedSet([1, 2, 3, 4, 5])
      >>> from operator import neg
      >>> ss = SortedSet([3, 1, 2, 5, 4], neg)
      >>> ss
      SortedSet([5, 4, 3, 2, 1], key=<built-in function neg>)
  
      :param iterable: initial values (optional)
      :param key: function used to extract comparison key (optional)
  
      """
      self._key = key
  
      # SortedSet._fromset calls SortedSet.__init__ after initializing the
      # _set attribute. So only create a new set if the _set attribute is not
      # already present.
  
      if not hasattr(self, "_set"):
          self._set = set()
  
      self._list = SortedList(self._set, key=key)
  
      # Expose some set methods publicly.
  
      _set = self._set
      self.isdisjoint = _set.isdisjoint
      self.issubset = _set.issubset
      self.issuperset = _set.issuperset
  
      # Expose some sorted list methods publicly.
  
      _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)
  
imports: from itertools import chain
  from operator import eq, ne, gt, ge, lt, le
  from textwrap import dedent
  from .sortedlist import SortedList, recursive_repr
label_desc: Use image node_id 1 to create a new SortedSet object from inherited base classes: MutableSet, Sequence with example: obj = SortedSet(iterable, key)