Skip to main content

sortedlist

Standard library Module View source
variable DEFAULT_LOAD_FACTOR
DEFAULT_LOAD_FACTOR = 1000
class SortedList
class SortedList[T]
Fields 1
T type
Constructors 1
__init__
__init__(self: Self)
Properties 1
left
@property
left(self: Self) -> T
Methods 2
clear
clear(self: Self)

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

add
add(self: Self, value: T)

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: Self) -> Generator[T]
__len__
__len__(self: Self) -> int
__bool__
__bool__(self: Self) -> bool