For example, if I want to get the max value which is less than 4 in
TreeSet(1, 3, 5), I have to use code like
TreeSet(1, 3, 5).to(4).max or
TreeSet(1, 3, 5).maxBy(x => if (x < 4) x else Int.MinValue). But these code will create an new intermediate TreeSet, which leads to higher complexity of
O(n). But in a red-black tree, this operation should only take
O(logn). And in Java,
floor are provided in TreeSet. Why they are missing in Scala?