Is there a way to do a binary search in Java 1.4 on a TreeSet using the same criterion that was used in it's Comparator as a search key without resorting to Arrays.binarySearch(MyTreeSet.asArray(),string_criterion, myComparator)? If not what about in Java 1.5 or 1.6?
posted 10 years ago
If you execute contains(), it is using binary search by virtue of TreeSet.
This implementation provides guaranteed log(n) time cost for the basic operations (add, remove and contains).