mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
simplification: use comparators combinators in intellij.platform.util module
This commit is contained in:
@@ -22,9 +22,6 @@ public interface Segment {
|
||||
int getStartOffset();
|
||||
int getEndOffset();
|
||||
|
||||
Comparator<Segment> BY_START_OFFSET_THEN_END_OFFSET = (r1, r2) -> {
|
||||
int result = r1.getStartOffset() - r2.getStartOffset();
|
||||
if (result == 0) result = r1.getEndOffset() - r2.getEndOffset();
|
||||
return result;
|
||||
};
|
||||
Comparator<Segment> BY_START_OFFSET_THEN_END_OFFSET =
|
||||
Comparator.comparingInt(Segment::getStartOffset).thenComparingInt(Segment::getEndOffset);
|
||||
}
|
||||
|
||||
@@ -1860,7 +1860,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
@NotNull
|
||||
@Contract(pure=true)
|
||||
public static <T extends Comparable<? super T>> List<T> sorted(@NotNull Collection<? extends T> list) {
|
||||
return sorted(list, (o1, o2) -> o1.compareTo(o2));
|
||||
return sorted(list, Comparator.naturalOrder());
|
||||
}
|
||||
|
||||
public static <T> void sort(@NotNull T[] a, @NotNull Comparator<? super T> comparator) {
|
||||
|
||||
@@ -252,13 +252,13 @@ public class DFSTBuilder<Node> {
|
||||
public Comparator<Node> comparator(boolean useNNumber) {
|
||||
if (useNNumber) {
|
||||
if (myNComparator == null) {
|
||||
myNComparator = (t, t1) -> myNodeToNNumber.get(t) - myNodeToNNumber.get(t1);
|
||||
myNComparator = Comparator.comparingInt(myNodeToNNumber::get);
|
||||
}
|
||||
return myNComparator;
|
||||
}
|
||||
else {
|
||||
if (myTComparator == null) {
|
||||
myTComparator = (t, t1) -> myNodeToTNumber.get(t) - myNodeToTNumber.get(t1);
|
||||
myTComparator = Comparator.comparingInt(myNodeToTNumber::get);
|
||||
}
|
||||
return myTComparator;
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ public class PagedFileStorage implements Forceable {
|
||||
for (Map.Entry<Integer, ByteBufferWrapper> entry : mySegments.entrySet()) {
|
||||
if ((entry.getKey() & FILE_INDEX_MASK) == index) {
|
||||
if (mineBuffers == null) {
|
||||
mineBuffers = new TreeMap<>((o1, o2) -> o1 - o2);
|
||||
mineBuffers = new TreeMap<>(Comparator.comparingInt(o -> o));
|
||||
}
|
||||
mineBuffers.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user