If I understand b-trees correctly, it should be easy and possible in logarithmic time to search for a key. If the key is not existent, it can return the next smaller and larger key; the neighbors of the given key if it would get inserted.
Does this functionality already exist?
One possible but complicated way to do it with the current API is to insert the key and then get an iterator to that key so that we can call next
on this iterator. Although, its also not clear how to get an iterator to a newly inserted element (see this question)
Why are those methods missing or am I missing something?