SortedList

Standard library class sortedlist.SortedList View source
class SortedList
class SortedList[T]
Fields 1
T type
Constructors 1
__init__
__init__(self)
Defined in sortedlist
Properties 1
left
@property
left(self)
Defined in sortedlist
Methods 2
clear
clear(self)
Defined in sortedlist

Remove all values from sorted list. Runtime complexity: $O(n)$

add
add(self, value: T)
Defined in sortedlist

Add value to sorted list. Runtime complexity: $O(\log(n))$ (approximate).

>>> sl = SortedList()
>>> sl.add(3)
>>> sl.add(1)
>>> sl.add(2)
>>> sl
SortedList([1, 2, 3])
Special methods 3
__iter__
__iter__(self)
Defined in sortedlist
__len__
__len__(self)
Defined in sortedlist
__bool__
__bool__(self)
Defined in sortedlist