Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complexity of IntervalTree.{begin,end} is O(1), not O(n).
They call self.boundary_table.iloc[0] (resp. [-1]), and self.boundary_table is a SortedDict. SortedDict.iloc is an instance of _IlocWrapper, whose __getitem__ only does: return self._dict._list[index] _dict is the SortedDict instance, and _dict._list is an instance of SortedList. Finally, SortedList.__item__ has special cases to perform in O(1) when the index is 0 or -1. References: * https://github.com/grantjenks/sorted_containers/blob/ccec8d4/sortedcontainers/sorteddict.py#L34-L40 * https://github.com/grantjenks/sorted_containers/blob/b62fe6a/sortedcontainers/sortedlist.py#L599-L602
- Loading branch information