Basically, find the left/right neighbor nodes.
! Don’t use upper_bound since lower_bound is enough.
- If perfect match, then lower_bound return value is all you need. No need for 2 nodes:)
- If no perfect match, then lower_bound() and prev(lower_bound)
- if X too low, then begin() alone is all we can get
- if X too high then prev(end()) alone is all we can get
NavigableMap.java interface offers four methods .. see closestMatch in sorted-collection: j^python^c++