X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=srcjar%2Fintervalstore%2Fimpl%2FNCListBuilder.java;h=678593d20065cda77c3bf46a41d1ca626da48c98;hb=801c367379086cc38bf4d3059a8e30ca9f4e78c0;hp=7d0b0130d889b4703856f02e4d685d0c576441d6;hpb=9577372b31a3c39a0690d3060503a76a2364a1d9;p=jalview.git diff --git a/srcjar/intervalstore/impl/NCListBuilder.java b/srcjar/intervalstore/impl/NCListBuilder.java index 7d0b013..678593d 100644 --- a/srcjar/intervalstore/impl/NCListBuilder.java +++ b/srcjar/intervalstore/impl/NCListBuilder.java @@ -48,36 +48,23 @@ import intervalstore.api.IntervalI; */ public class NCListBuilder { + /** + * Compares two intervals in a way that will sort a list by start position + * ascending, then by length descending + */ class NCListComparator implements Comparator { - /** - * Compares two intervals in a way that will sort a list by start position - * ascending, then by length descending. Answers - *
    - *
  • a negative value if o1.begin < o2.begin
  • - *
  • else a positive value if o1.begin > o2.begin
  • - *
  • else a negative value if o1.end > o2.end
  • - *
  • else a positive value of o1.end < o2.end
  • - *
  • else zero
  • - */ @Override public int compare(V o1, V o2) { int order = Integer.compare(o1.getBegin(), o2.getBegin()); if (order == 0) { - /* - * if tied on start position, longer length sorts to left - * i.e. the negation of normal ordering by length - */ order = Integer.compare(o2.getEnd(), o1.getEnd()); } return order; } } - - private Comparator comparator = new NCListComparator<>(); /** * Default constructor @@ -87,17 +74,6 @@ public class NCListBuilder } /** - * Answers a comparator which sorts items of type T by start position - * ascending, and within that by end position (length) descending) - * - * @return - */ - Comparator getComparator() - { - return comparator; - } - - /** * Sorts and traverses the ranges to identify sublists, whose start intervals * are overlapping or disjoint but not mutually contained. Answers a list of * start-end indices of the sorted list of ranges. @@ -113,7 +89,7 @@ public class NCListBuilder * sort by start ascending, length descending, so that * contained intervals follow their containing interval */ - Collections.sort(ranges, comparator); + Collections.sort(ranges, IntervalI.COMPARE_BEGIN_ASC_END_DESC); int listStartIndex = 0;