-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API of SortedContainer #918
Comments
If you are interested in these changes, I can help with submitting a pull request. |
I would recommend against changing the API for As for loosening the restriction in the API of |
I see. Indeed, the changes in |
Yes, it would make sense to implement |
In my application, I find it's useful to define the following APIs for SortedContainer.
The first three functions
checkbounds
,nextind
,prevind
are straightforward and align well with existing APIs. Thegetindex
functions forIntSemiToken
have been implemented forSortedDict
andSortedMultiDict
, which return only the values. I modified them to return key-value pairs, because it is natural to do so in my application. Besides, given the existence of anothergetindex
function that retrieves thevalue
using thekey
, I think retrievingkey-value
pairs usingIntSemiToken
seems a natural choice. Of course, it might not be a good choice in general. How do you think about these changes?Here is a piece of my application code for motivating the changes. It uses the general APIs for sorted containers to simultaneously handle sorted AbstractVector and SortedDict.
I also tried to use the
SortedSet
as the container in this code block but encountered a problem thatsearchsortedlast
forSortedSet
tries to convert thet::Real
toObservation
before comparing it to other observations in the container. I think this compulsory conversion might not be necessary. In some cases, it is natural to directly compare objects of different types. The above code is an example.The text was updated successfully, but these errors were encountered: