Hi, I'm trying to solve this problem from the ICPC's inaugural North America Championship: https://open.kattis.com/contests/nac20open/problems/bomas

A key piece of the solution is to build the tree of nested circles. To do this efficiently, one performs a line sweep: imagine a vertical line starting at some very negative x and gradually moving to the right. At any moment, we maintain the upper and lower arcs of all circles that intersect the current x coordinate, sorted by the y coordinate of this intersection. Since, for each arc, y is a function of x, this means the arcs are sorted by keys that vary with time.

Thus, I want to put my arcs into a BTreeSet with a custom comparator function that computes these keys on demand. The comparator would have read-only access to the x value, which is modified by my line sweep program. I understand that any changes in keys that affect the relative order of elements in the BTreeSet would be a logic error; fortunately, changes in relative order will never occur because the circles in question do not intersect. Nonetheless, I need to be able to perform successor and predecessor queries during the line sweep, in order to insert *new* arcs in the correct sorted position when the line sweep reaches the left endpoint of a new circle.

Are there any plans for BTreeSet to support custom comparators such as this, or does an alternative solution currently exist in the Rust standard library?

Thanks!