Provides an ordering of {@code ScoringTypedOffsetRange} by their degree of overlap with a
reference {@code ScoringTypedOffsetRange}, from least overlap to most.
549971
public static <OffsetType extends Offset<OffsetType>> Ordering<ScoringTypedOffsetRange<OffsetType>>
    orderByOverlapWith(final ScoringTypedOffsetRange<OffsetType> reference) {
    return new Ordering<ScoringTypedOffsetRange<OffsetType>>() {
      @Override
      public int compare(final ScoringTypedOffsetRange<OffsetType> left, final
      ScoringTypedOffsetRange<OffsetType> right) {
        final int leftIntersectionSize =
            left.offsetRange().intersection(reference.offsetRange())
                .transform(OffsetRange.lengthFunction()).or(0);
        final int rightIntersectionSize = right.offsetRange().intersection(reference.offsetRange())
            .transform(OffsetRange.lengthFunction()).or(0);

        return Ints.compare(leftIntersectionSize, rightIntersectionSize);
      }
    };
  }
1605
public static <C extends Comparable> Ordering<Range<C>> reverseOrderingByUpperEndpoint() {
        Ordering<Range<C>> orderingByUpperEndpoint = orderingByUpperEndpoint();
        return orderingByUpperEndpoint.reverse();
    }
1319794
Row<T>[] sortItems(final long threshold, final ErrorType errorType) {
    final ArrayList<Row<T>> rowList = new ArrayList<>();
    final ReversePurgeItemHashMap.Iterator<T> iter = hashMap.iterator();
    if (errorType == ErrorType.NO_FALSE_NEGATIVES) {
      while (iter.next()) {
        final long est = getEstimate(iter.getKey());
        final long ub = getUpperBound(iter.getKey());
        final long lb = getLowerBound(iter.getKey());
        if (ub >= threshold) {
          final Row<T> row = new Row<>(iter.getKey(), est, ub, lb);
          rowList.add(row);
        }
      }
    } else { //NO_FALSE_POSITIVES
      while (iter.next()) {
        final long est = getEstimate(iter.getKey());
        final long ub = getUpperBound(iter.getKey());
        final long lb = getLowerBound(iter.getKey());
        if (lb >= threshold) {
          final Row<T> row = new Row<>(iter.getKey(), est, ub, lb);
          rowList.add(row);
        }
      }
    }

    // descending order
    rowList.sort(new Comparator<Row<T>>() {
      @Override
      public int compare(final Row<T> r1, final Row<T> r2) {
        return r2.compareTo(r1);
      }
    });

    @SuppressWarnings("unchecked")
    final Row<T>[] rowsArr =
      rowList.toArray((Row<T>[]) Array.newInstance(Row.class, rowList.size()));
    return rowsArr;
  }
1287695
private void initQualityScoreChildrenSettings(QualityScoreSettings qualityScoreSettings) {
    ScoreComponentSettings qualityCCSettings = Utils.getInstanceIfNull(qualityScoreSettings.getCodeCoverage(), ScoreComponentSettings.class);
    qualityCCSettings.setCriteria(
      Utils.mergeCriteria(qualityScoreSettings.getCriteria(), qualityCCSettings.getCriteria())
    );
    qualityScoreSettings.setCodeCoverage(qualityCCSettings);

    ScoreComponentSettings qualityUTSettings = Utils.getInstanceIfNull(qualityScoreSettings.getUnitTests(), ScoreComponentSettings.class);
    qualityUTSettings.setCriteria(
      Utils.mergeCriteria(qualityScoreSettings.getCriteria(), qualityUTSettings.getCriteria())
    );
    qualityScoreSettings.setUnitTests(qualityUTSettings);

    QualityScoreSettings.ViolationsScoreSettings violationsSettings = Utils.getInstanceIfNull(qualityScoreSettings.getViolations(), QualityScoreSettings.ViolationsScoreSettings.class);
    violationsSettings.setCriteria(
      Utils.mergeCriteria(qualityScoreSettings.getCriteria(), violationsSettings.getCriteria())
    );
    qualityScoreSettings.setViolations(violationsSettings);
  }
955482
private static List<ClasspathElement> orderClasspathElements(
            final Collection<Entry<Integer, ClasspathElement>> classpathEltsIndexed) {
        final List<Entry<Integer, ClasspathElement>> classpathEltsIndexedOrdered = new ArrayList<>(
                classpathEltsIndexed);
        CollectionUtils.sortIfNotEmpty(classpathEltsIndexedOrdered, INDEXED_CLASSPATH_ELEMENT_COMPARATOR);
        final List<ClasspathElement> classpathEltsOrdered = new ArrayList<>(classpathEltsIndexedOrdered.size());
        for (final Entry<Integer, ClasspathElement> ent : classpathEltsIndexedOrdered) {
            classpathEltsOrdered.add(ent.getValue());
        }
        return classpathEltsOrdered;
    }
271743
public org.grails.datastore.mapping.query.api.Criteria order(Order o) {
        final Criteria criteria = this.criteria;
        addOrderInternal(criteria, o);
        return this;
    }
240900
@Override
  public MtasDataItemNumberComparator<Long> getCompareValue1() {
    switch (sortType) {
    case CodecUtil.STATS_TYPE_SUM:
      return new MtasDataItemNumberComparator<Long>(valueSum, sortDirection);
    case CodecUtil.STATS_TYPE_MAX:
      return new MtasDataItemNumberComparator<Long>(valueMax, sortDirection);
    case CodecUtil.STATS_TYPE_MIN:
      return new MtasDataItemNumberComparator<Long>(valueMin, sortDirection);
    case CodecUtil.STATS_TYPE_SUMSQ:
      return new MtasDataItemNumberComparator<Long>(valueSumOfSquares,
          sortDirection);
    default:
      return null;
    }
  }
1087864
public void sort(final IndexedSortable s, int p, int r) {
		int recordsPerSegment = s.recordsPerSegment();
		int recordSize = s.recordSize();
		int maxOffset = recordSize * (recordsPerSegment - 1);

		int pN = p / recordsPerSegment;
		int pO = (p % recordsPerSegment) * recordSize;

		int rN = r / recordsPerSegment;
		int rO = (r % recordsPerSegment) * recordSize;

		sortInternal(s, recordsPerSegment, recordSize, maxOffset, p, pN, pO, r, rN, rO, getMaxDepth(r - p));
	}
373951
@PublicEvolving
	public TypeComparator<T> createComparator(int[] logicalKeyFields, boolean[] orders, int logicalFieldOffset, ExecutionConfig config) {

		TypeComparatorBuilder<T> builder = createTypeComparatorBuilder();

		builder.initializeTypeComparatorBuilder(logicalKeyFields.length);

		for (int logicalKeyFieldIndex = 0; logicalKeyFieldIndex < logicalKeyFields.length; logicalKeyFieldIndex++) {
			int logicalKeyField = logicalKeyFields[logicalKeyFieldIndex];
			int logicalField = logicalFieldOffset; // this is the global/logical field number
			boolean comparatorAdded = false;

			for (int localFieldId = 0; localFieldId < this.getArity() && logicalField <= logicalKeyField && !comparatorAdded; localFieldId++) {
				TypeInformation<?> localFieldType = this.getTypeAt(localFieldId);
				
				if (localFieldType instanceof AtomicType && logicalField == logicalKeyField) {
					// we found an atomic key --> create comparator
					builder.addComparatorField(
						localFieldId,
						((AtomicType<?>) localFieldType).createComparator(
							orders[logicalKeyFieldIndex],
							config));

					comparatorAdded = true;
				}
				// must be composite type and check that the logicalKeyField is within the bounds
				// of the composite type's logical fields
				else if (localFieldType instanceof CompositeType &&
					logicalField <= logicalKeyField &&
					logicalKeyField <= logicalField + (localFieldType.getTotalFields() - 1)) {
					// we found a compositeType that is containing the logicalKeyField we are looking for --> create comparator
					builder.addComparatorField(
						localFieldId,
						((CompositeType<?>) localFieldType).createComparator(
							new int[]{logicalKeyField},
							new boolean[]{orders[logicalKeyFieldIndex]},
							logicalField,
							config)
					);

					comparatorAdded = true;
				}

				if (localFieldType instanceof CompositeType) {
					// we need to subtract 1 because we are not accounting for the local field (not accessible for the user)
					logicalField += localFieldType.getTotalFields() - 1;
				}
				
				logicalField++;
			}

			if (!comparatorAdded) {
				throw new IllegalArgumentException("Could not add a comparator for the logical" +
					"key field index " + logicalKeyFieldIndex + ".");
			}
		}

		return builder.createTypeComparator(config);
	}
240228
public Annotation ceiling(Annotation annotation, AnnotationType type) {
      if (annotation == null || type == null) {
         return Fragments.detachedEmptyAnnotation();
      }
      for (Annotation a : Collect.asIterable(new NodeIterator(root, annotation.end(), Integer.MAX_VALUE, type, true))) {
         if (a.isInstance(type) && a != annotation) {
            return a;
         }
      }
      return Fragments.detachedEmptyAnnotation();
   }
813647
public static <T extends Comparable<T>> Pair<T, T> ordered(T lhs, T rhs) {
        return new MakeOrder<T>(new ComparableComparator<T>()).apply(lhs, rhs);
    }
295088
protected void cumulateDistance(final List<LightweightTypeReference> references, Multimap<JvmType, LightweightTypeReference> all,
			Multiset<JvmType> cumulatedDistance) {
		for(LightweightTypeReference other: references) {
			Multiset<JvmType> otherDistance = LinkedHashMultiset.create();
			initializeDistance(other, all, otherDistance);
			cumulatedDistance.retainAll(otherDistance);
			for(Multiset.Entry<JvmType> typeToDistance: otherDistance.entrySet()) {
				if (cumulatedDistance.contains(typeToDistance.getElement()))
					cumulatedDistance.add(typeToDistance.getElement(), typeToDistance.getCount());
			}
		}
	}
27660
public void setQualificationTypes(java.util.Collection<QualificationType> qualificationTypes) {
        if (qualificationTypes == null) {
            this.qualificationTypes = null;
            return;
        }

        this.qualificationTypes = new java.util.ArrayList<QualificationType>(qualificationTypes);
    }
440561
public static <E> Ordering<Multiset.Entry<E>>
  byCountDescendingThenItemAscendingOrdering(Comparator<? super E> itemComparator) {
    final Ordering<Multiset.Entry<E>> byCount = byCountOrdering();
    final Ordering<Multiset.Entry<E>> byCountReversed = byCount.reverse();
    final Ordering<Multiset.Entry<E>> byElement = byElementOrdering(itemComparator);
    return byCountReversed.compound(byElement);
  }
719032
public static void defineOrder(ProcessedInput processedInput, QueryParameters parameters) {
        String parameterName = null;

        for (int i = 0; i < processedInput.getAmountOfParameters(); i++) {
            parameterName = processedInput.getParameterName(i);

            if (parameterName != null) {
                parameters.updatePosition(parameterName, i);
            }
        }
    }
1259838
@Override
  public int compareTo(final Span s) {
    if (getStart() < s.getStart()) {
      return -1;
    } else if (getStart() == s.getStart()) {
      if (getEnd() > s.getEnd()) {
        return -1;
      } else if (getEnd() < s.getEnd()) {
        return 1;
      } else {
        // compare the type
        if (getType() == null && s.getType() == null) {
          return 0;
        } else if (getType() != null && s.getType() != null) {
          // use type lexicography order
          return getType().compareTo(s.getType());
        } else if (getType() != null) {
          return -1;
        }
        return 1;
      }
    } else {
      return 1;
    }
  }
747391
public Annotation getRangeList(int i) {
    if (OntRelationMention_Type.featOkTst && ((OntRelationMention_Type)jcasType).casFeat_rangeList == null)
      jcasType.jcas.throwFeatMissing("rangeList", "de.julielab.jules.types.OntRelationMention");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((OntRelationMention_Type)jcasType).casFeatCode_rangeList), i);
    return (Annotation)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((OntRelationMention_Type)jcasType).casFeatCode_rangeList), i)));}