Exemple #1
0
 public void sort(Collection<SortBySiblingSeg> segs, OrderGraph graph) {
   for (SortBySiblingSeg seg : segs) {
     for (Pair<Node, List<Node>> pair : seg.siblingsByTarget) {
       Node target = pair.first;
       for (Node sibling : pair.second) {
         if (before) {
           graph.order(target, sibling, priority);
         } else {
           graph.order(sibling, target, priority);
         }
       }
     }
   }
 }
Exemple #2
0
 protected <T> void totalOrder(
     List<Pair<String, T>> items, Comparator<Pair<String, T>> comparator, OrderGraph graph) {
   Collections.sort(items, comparator);
   int size = items.size();
   for (int i = 0; i < size - 1; i++) {
     Pair<String, T> item1 = items.get(i);
     for (int j = i + 1; j < size; j++) {
       Pair<String, T> item2 = items.get(j);
       int pairOrder = comparator.compare(item1, item2);
       assert pairOrder <= 0;
       if (pairOrder != 0) graph.order(item1.first, item2.first, priority);
     }
   }
 }