DanielStutzbach / blist

A list-like type with better asymptotic performance and similar performance on small lists
Other
313 stars 35 forks source link

sortedlist needs an insort_left-like method #51

Open tomas-teijeiro opened 11 years ago

tomas-teijeiro commented 11 years ago

Although sortedlist provides methods to obtain the appropriate index to introduce a new element in pre-order and post-order (a.k.a. bisect_left and bisect_right), it is impossible to use those methods to introduce a new element in the desired ordered position, because the 'add' method only supports post-order. To achieve this, at this time you need to access to protected attributes and methods, which is not very convenient.

grantjenks commented 9 years ago

@tomas-teijeiro Have you tried the SortedContainers module? It has a SortedList with bisect_left and insert methods. You could use those to implement your add_left method.