I'm working on an implentation of a Suffix Array to be used for speeding up phrase searches.
I have an array of "Suffix"-objects, this is the Suffix Array. Each Suffix-object has two values, document and position.
I have a Comparator that sorts this array based on a lookup in a dictionary of strings using the two values document and position. (For example, one suffix object with document=1, position=5 points to "fish" and another object points to "cake". "Cake" will be sorted in front of "fish". This works just fine, and the suffix array is sorted as expected in lexographical order
Now, however, I want to do a binary search lookup in this suffix array, and the input this time is a string. How can I use Arrays.binarySearch() with the Comparator I made to compare a String key (the phrase I'm searching for) to search the suffix array? It would be trivial to compare the String with the Suffix object if the binarySearch() method would let me somehow do it in the Comparator...