Example usage for org.apache.lucene.util CollectionUtil introSort

List of usage examples for org.apache.lucene.util CollectionUtil introSort

Introduction

In this page you can find the example usage for org.apache.lucene.util CollectionUtil introSort.

Prototype

public static <T extends Comparable<? super T>> void introSort(List<T> list) 

Source Link

Document

Sorts the given random access List in natural order.

Usage

From source file:org.elasticsearch.common.collect.Iterators2Tests.java

License:Apache License

public void testDeduplicateSorted() {
    final List<String> list = Lists.newArrayList();
    for (int i = randomInt(100); i >= 0; --i) {
        final int frequency = randomIntBetween(1, 10);
        final String s = randomAsciiOfLength(randomIntBetween(2, 20));
        for (int j = 0; j < frequency; ++j) {
            list.add(s);/*from  w  ww.  j a  v  a 2s .co  m*/
        }
    }
    CollectionUtil.introSort(list);
    final List<String> deduplicated = Lists.newArrayList();
    for (Iterator<String> it = Iterators2.deduplicateSorted(list.iterator(), Ordering.natural()); it
            .hasNext();) {
        deduplicated.add(it.next());
    }
    assertEquals(Lists.newArrayList(Sets.newTreeSet(list)), deduplicated);
}