Alex Chun wrote:classes (String[]) and their run time (long[]). I need to sort classes from high speed to low speed.
Please avoid long lines because they are difficult to read.
Why are you using a Long rather than a long in the Searcher class?
Parallel arrays in line 15? They are error‑prone. What if the two arrays are not the same length.
Why are you using parallelSort in line 25 rather than ordinary Arrays#sort?
Have you tried dispensing with the Comparator as a class and using a λ?
if you manage to get your parallel arrays the same size
I presume you know why that factory method is probably better static?Alex Chun wrote: . . . corrected. . . . corrected. . . . corrected. . . .
marked method arrayOfSearcher such as static.
An IndexOutOfBoundsException, more likely.. . .
As I understand to throw IOEception, isn't?
In that case parallelSort probably runs faster, yes.. . . There are may be until 100000 classes. This case is better use parallelSort. . . .
Comparator is a Functional Interface. That means you can convert it to a function. Haven't got time to explain any more now, I am afraid.I don't understand what you mean. I use Comparator the only way.
Yes.. . . do you mean String[] classNames, long[] modificationDates?
. . .Campbell Ritchie wrote:I presume you know why that factory method is probably better static?
. . .An IndexOutOfBoundsException, more likely.
if you manage to get your parallel arrays the same size[/qoute] . . . do you mean String[] classNames, long[] modificationDates?...Yes.
Liutauras Vilda wrote:Lines 30 - 34. Notice something wrong?
Where this 12 comes from? shouldn't be instead value taken from parameter? "start" is not used.
No. Because you may need to create such an array before any instances exist.Alex Chun wrote:
. . .Myself wrote:I presume you know why that factory method is probably better static?
Because we need this array once for class neither for every object
. . .
Campbell Ritchie wrote:If a method is in an interface (which I didn't notice) then it is non static (Well, in Java8 you can have static methods in interfaces.).
If you are linking first letters to words, how about a Map<Character, List<String>>? That will save you the problem of going through the array every time you run that method.
If you have the List of words sorted you can use a binary search.
Consider Paul's rocket mass heater. |