/** * Sorts the given array using the {@link Comparator}. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. */ public static <T> void introSort(T[] a, Comparator<? super T> comp) { introSort(a, 0, a.length, comp); }
/** * Sorts the given array in natural order. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. */ public static <T extends Comparable<? super T>> void introSort(T[] a) { introSort(a, 0, a.length); }
/** * Sorts the given array slice in natural order. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. * @param fromIndex start index (inclusive) * @param toIndex end index (exclusive) */ public static <T extends Comparable<? super T>> void introSort(T[] a, int fromIndex, int toIndex) { if (toIndex-fromIndex <= 1) return; introSort(a, fromIndex, toIndex, Comparator.naturalOrder()); }
@Override void finishDocument() throws IOException { if (!hasVectors) { return; } // Fields in term vectors are UTF16 sorted: ArrayUtil.introSort(perFields, 0, numVectorFields); initTermVectorsWriter(); fill(docState.docID); // Append term vectors to the real outputs: writer.startDocument(numVectorFields); for (int i = 0; i < numVectorFields; i++) { perFields[i].finishDocument(); } writer.finishDocument(); assert lastDocID == docState.docID: "lastDocID=" + lastDocID + " docState.docID=" + docState.docID; lastDocID++; super.reset(); resetFields(); }
/** * Sorts the given array in natural order. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. */ public static <T extends Comparable<? super T>> void introSort(T[] a) { introSort(a, 0, a.length); }
/** * Sorts the given array using the {@link Comparator}. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. */ public static <T> void introSort(T[] a, Comparator<? super T> comp) { introSort(a, 0, a.length, comp); }
/** * Sorts the given array using the {@link Comparator}. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. */ public static <T> void introSort(T[] a, Comparator<? super T> comp) { introSort(a, 0, a.length, comp); }
/** * Sorts the given array in natural order. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. */ public static <T extends Comparable<? super T>> void introSort(T[] a) { introSort(a, 0, a.length); }
/** * Sorts the given array using the {@link Comparator}. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. */ public static <T> void introSort(T[] a, Comparator<? super T> comp) { introSort(a, 0, a.length, comp); }
/** * Sorts the given array in natural order. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. */ public static <T extends Comparable<? super T>> void introSort(T[] a) { introSort(a, 0, a.length); }
/** * Sorts the given array slice in natural order. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. * @param fromIndex start index (inclusive) * @param toIndex end index (exclusive) */ public static <T extends Comparable<? super T>> void introSort(T[] a, int fromIndex, int toIndex) { if (toIndex-fromIndex <= 1) return; introSort(a, fromIndex, toIndex, Comparator.naturalOrder()); }
private ScoreDoc[] docIdOrder(ScoreDoc[] scoreDocs) { ScoreDoc[] clone = new ScoreDoc[scoreDocs.length]; System.arraycopy(scoreDocs, 0, clone, 0, scoreDocs.length); ArrayUtil.introSort(clone, (a, b) -> Integer.compare(a.doc, b.doc)); return clone; }
/** * Sorts the given array slice in natural order. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. * @param fromIndex start index (inclusive) * @param toIndex end index (exclusive) */ public static <T extends Comparable<? super T>> void introSort(T[] a, int fromIndex, int toIndex) { if (toIndex-fromIndex <= 1) return; introSort(a, fromIndex, toIndex, ArrayUtil.<T>naturalComparator()); }
/** * Sorts the given array slice in natural order. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. * @param fromIndex start index (inclusive) * @param toIndex end index (exclusive) */ public static <T extends Comparable<? super T>> void introSort(T[] a, int fromIndex, int toIndex) { if (toIndex-fromIndex <= 1) return; introSort(a, fromIndex, toIndex, ArrayUtil.<T>naturalComparator()); }
@Override void finishDocument() throws IOException { if (!hasVectors) { return; } // Fields in term vectors are UTF16 sorted: ArrayUtil.introSort(perFields, 0, numVectorFields); initTermVectorsWriter(); fill(docState.docID); // Append term vectors to the real outputs: writer.startDocument(numVectorFields); for (int i = 0; i < numVectorFields; i++) { perFields[i].finishDocument(); } writer.finishDocument(); assert lastDocID == docState.docID: "lastDocID=" + lastDocID + " docState.docID=" + docState.docID; lastDocID++; super.reset(); resetFields(); }
@Override void finishDocument() throws IOException { if (!hasVectors) { return; } // Fields in term vectors are UTF16 sorted: ArrayUtil.introSort(perFields, 0, numVectorFields); initTermVectorsWriter(); fill(docState.docID); // Append term vectors to the real outputs: writer.startDocument(numVectorFields); for (int i = 0; i < numVectorFields; i++) { perFields[i].finishDocument(); } writer.finishDocument(); assert lastDocID == docState.docID: "lastDocID=" + lastDocID + " docState.docID=" + docState.docID; lastDocID++; super.reset(); resetFields(); }
@Override void finishDocument() throws IOException { if (!hasVectors) { return; } // Fields in term vectors are UTF16 sorted: ArrayUtil.introSort(perFields, 0, numVectorFields); initTermVectorsWriter(); fill(docState.docID); // Append term vectors to the real outputs: writer.startDocument(numVectorFields); for (int i = 0; i < numVectorFields; i++) { perFields[i].finishDocument(); } writer.finishDocument(); assert lastDocID == docState.docID: "lastDocID=" + lastDocID + " docState.docID=" + docState.docID; lastDocID++; super.reset(); resetFields(); }