Tabnine Logo
Collections.reverseOrder
Code IndexAdd Tabnine to your IDE (free)

How to use
reverseOrder
method
in
java.util.Collections

Best Java code snippets using java.util.Collections.reverseOrder (Showing top 20 results out of 5,607)

Refine searchRefine arrow

  • Collections.sort
  • Test.<init>
  • Assert.assertEquals
  • List.add
  • Arrays.sort
origin: google/guava

 @Override
 public List<String> order(List<String> insertionOrder) {
  Collections.sort(insertionOrder, Collections.reverseOrder());
  return insertionOrder;
 }
}
origin: stackoverflow.com

 sort(T[] a, Comparator<? super T> c) 

Arrays.sort(a, Collections.reverseOrder());
origin: robolectric/robolectric

@Nonnull
private <T> List<Class<? extends T>> prioritize(Iterable<Class<? extends T>> iterable) {
 List<Class<? extends T>> serviceClasses = new ArrayList<>();
 for (Class<? extends T> serviceClass : iterable) {
  serviceClasses.add(serviceClass);
 }
 Comparator<Class<? extends T>> c = reverseOrder(comparing(PluginFinder::priority));
 c = c.thenComparing(Class::getName);
 serviceClasses.sort(c);
 return serviceClasses;
}
origin: stagemonitor/stagemonitor

private static List<ElasticsearchAvailabilityObserver> initElasticsearchAvailabilityObservers(ConfigurationRegistry configurationRegistry) {
  final List<ElasticsearchAvailabilityObserver> elasticsearchAvailabilityObservers = new ArrayList<ElasticsearchAvailabilityObserver>();
  ServiceLoader<ElasticsearchAvailabilityObserver> observers = ServiceLoader
      .load(ElasticsearchAvailabilityObserver.class, CorePlugin.class.getClassLoader());
  for (ElasticsearchAvailabilityObserver elasticsearchAvailabilityObserver : observers) {
    elasticsearchAvailabilityObservers.add(elasticsearchAvailabilityObserver);
    elasticsearchAvailabilityObserver.init(configurationRegistry);
  }
  
  Collections.sort(elasticsearchAvailabilityObservers, Collections.reverseOrder(new Comparator<ElasticsearchAvailabilityObserver>() {
    @Override
    public int compare(ElasticsearchAvailabilityObserver o1, ElasticsearchAvailabilityObserver o2) {
      return (o1.getPriority() < o2.getPriority()) ? -1 : ((o1.getPriority() == o2.getPriority()) ? 0 : 1);
    }
  }));
  return elasticsearchAvailabilityObservers;
}
origin: org.apache.spark/spark-core_2.10

@Test
public void sortByKey() {
 List<Tuple2<Integer, Integer>> pairs = new ArrayList<>();
 pairs.add(new Tuple2<>(0, 4));
 pairs.add(new Tuple2<>(3, 2));
 pairs.add(new Tuple2<>(-1, 1));
 JavaPairRDD<Integer, Integer> rdd = sc.parallelizePairs(pairs);
 // Default comparator
 JavaPairRDD<Integer, Integer> sortedRDD = rdd.sortByKey();
 assertEquals(new Tuple2<>(-1, 1), sortedRDD.first());
 List<Tuple2<Integer, Integer>> sortedPairs = sortedRDD.collect();
 assertEquals(new Tuple2<>(0, 4), sortedPairs.get(1));
 assertEquals(new Tuple2<>(3, 2), sortedPairs.get(2));
 // Custom comparator
 sortedRDD = rdd.sortByKey(Collections.reverseOrder(), false);
 assertEquals(new Tuple2<>(-1, 1), sortedRDD.first());
 sortedPairs = sortedRDD.collect();
 assertEquals(new Tuple2<>(0, 4), sortedPairs.get(1));
 assertEquals(new Tuple2<>(3, 2), sortedPairs.get(2));
}
origin: wildfly/wildfly

  available.add(encoding);
Collections.sort(available, Collections.reverseOrder());
resultingMappings.addAll(available);
origin: apache/mahout

@Test
public void testDepth() {
 List<Integer> totals = Lists.newArrayList();
 for (int i = 0; i < 1000; i++) {
  ChineseRestaurant x = new ChineseRestaurant(10);
  Multiset<Integer> counts = HashMultiset.create();
  for (int j = 0; j < 100; j++) {
   counts.add(x.sample());
  }
  List<Integer> tmp = Lists.newArrayList();
  for (Integer k : counts.elementSet()) {
   tmp.add(counts.count(k));
  }
  Collections.sort(tmp, Collections.reverseOrder());
  while (totals.size() < tmp.size()) {
   totals.add(0);
  }
  int j = 0;
  for (Integer k : tmp) {
   totals.set(j, totals.get(j) + k);
   j++;
  }
 }
 // these are empirically derived values, not principled ones
 assertEquals(25000.0, (double) totals.get(0), 1000);
 assertEquals(24000.0, (double) totals.get(1), 1000);
 assertEquals(8000.0, (double) totals.get(2), 200);
 assertEquals(1000.0, (double) totals.get(15), 50);
 assertEquals(1000.0, (double) totals.get(20), 40);
}
origin: apache/incubator-druid

@Test
public void testRulesRunOnNonOvershadowedSegmentsOnly()
         mockPeon
     ).collect(Collectors.toCollection(() -> new TreeSet<>(Collections.reverseOrder())))
 CoordinatorStats stats = afterParams.getCoordinatorStats();
 Assert.assertEquals(1, stats.getTiers("assignedCount").size());
 Assert.assertEquals(1, stats.getTieredStat("assignedCount", "_default_tier"));
 Assert.assertTrue(stats.getTiers("unassignedCount").isEmpty());
 Assert.assertTrue(stats.getTiers("unassignedSize").isEmpty());
 Assert.assertEquals(2, availableSegments.size());
 Assert.assertEquals(availableSegments, params.getAvailableSegments());
 Assert.assertEquals(availableSegments, afterParams.getAvailableSegments());
origin: apache/hbase

@Test
public void testFloat32() {
 Float[] vals =
   assertEquals("Surprising return value.",
    5, OrderedBytes.encodeFloat32(buf1, vals[i], ord));
   assertEquals("Broken test: serialization did not consume entire buffer.",
    buf1.getLength(), buf1.getPosition());
   assertEquals("Surprising serialized length.", 5, buf1.getPosition() - 1);
   assertEquals("Buffer underflow.", 0, a[0]);
   assertEquals("Buffer underflow.", 0, a[1]);
  Arrays.sort(encoded, Bytes.BYTES_COMPARATOR);
  Float[] sortedVals = Arrays.copyOf(vals, vals.length);
  if (ord == Order.ASCENDING) Arrays.sort(sortedVals);
  else Arrays.sort(sortedVals, Collections.reverseOrder());
origin: apache/ignite

  /**
   * Checks reverse order of exchangeFutures.
   *
   * @throws Exception If failed.
   */
  @Test
  public void testExchangeFutures() throws Exception {
    GridCachePartitionExchangeManager mgr = ((IgniteKernal)grid(0)).internalCache(DEFAULT_CACHE_NAME).context().shared().exchange();

    for (int i = 1; i <= 10; i++) {
      startGrid(i);

      List<GridDhtPartitionsExchangeFuture> futs = mgr.exchangeFutures();

      List<GridDhtPartitionsExchangeFuture> sortedFuts = new ArrayList<>(futs);

      Collections.sort(sortedFuts, Collections.reverseOrder());

      for (int j = 0; j < futs.size(); j++)
        assertEquals(futs.get(j), sortedFuts.get(j));
    }
  }
}
origin: apache/incubator-druid

@Test
public void testRun()
     Stream.of(
       new ServerHolder(druidServer, mockPeon)
     ).collect(Collectors.toCollection(() -> new TreeSet<>(Collections.reverseOrder())))
   ));
origin: apache/hbase

 @Test
 public void testApplyDescending() {
  byte[][] vals = new byte[VALS.length][];
  byte[][] ordered = new byte[VALS.length][];
  for (int i = 0; i < VALS.length; i++) {
   vals[i] = Arrays.copyOf(VALS[i], VALS[i].length);
   ordered[i] = Arrays.copyOf(VALS[i], VALS[i].length);
   DESCENDING.apply(ordered[i]);
  }

  Arrays.sort(vals, Collections.reverseOrder(Bytes.BYTES_COMPARATOR));
  Arrays.sort(ordered, Bytes.BYTES_COMPARATOR);

  for (int i = 0; i < vals.length; i++) {
   DESCENDING.apply(ordered[i]);
   assertArrayEquals(vals[i], ordered[i]);
  }

  byte[] expected = new byte[] { VALS[0][0], DESCENDING.apply(VALS[0][1]), VALS[0][2] };
  byte[] rangeApply = Arrays.copyOf(VALS[0], VALS[0].length);
  DESCENDING.apply(rangeApply, 1, 1);
  assertArrayEquals(expected, rangeApply);
 }
}
origin: apache/storm

Collections.sort(sortedKeys, Collections.reverseOrder());
        break;
      chunkList.add(it.next());
    ret.add(chunkList);
origin: org.apache.spark/spark-core

@Test
public void sortByKey() {
 List<Tuple2<Integer, Integer>> pairs = new ArrayList<>();
 pairs.add(new Tuple2<>(0, 4));
 pairs.add(new Tuple2<>(3, 2));
 pairs.add(new Tuple2<>(-1, 1));
 JavaPairRDD<Integer, Integer> rdd = sc.parallelizePairs(pairs);
 // Default comparator
 JavaPairRDD<Integer, Integer> sortedRDD = rdd.sortByKey();
 assertEquals(new Tuple2<>(-1, 1), sortedRDD.first());
 List<Tuple2<Integer, Integer>> sortedPairs = sortedRDD.collect();
 assertEquals(new Tuple2<>(0, 4), sortedPairs.get(1));
 assertEquals(new Tuple2<>(3, 2), sortedPairs.get(2));
 // Custom comparator
 sortedRDD = rdd.sortByKey(Collections.reverseOrder(), false);
 assertEquals(new Tuple2<>(-1, 1), sortedRDD.first());
 sortedPairs = sortedRDD.collect();
 assertEquals(new Tuple2<>(0, 4), sortedPairs.get(1));
 assertEquals(new Tuple2<>(3, 2), sortedPairs.get(2));
}
origin: neo4j-contrib/neo4j-apoc-procedures

@Test
public void shouldGeneratePowerLawDistribution() {
  GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase();
  try {
    new Neo4jGraphGenerator(database).generateGraph(getGeneratorConfiguration(100, 2));
    List<Integer> degrees = new LinkedList<>();
    try (Transaction tx = database.beginTx()) {
      for (Node node : database.getAllNodes()) {
        degrees.add(node.getDegree());
      }
      tx.success();
    }
    Collections.sort(degrees, Collections.reverseOrder());
    //todo make this an automated test
    //System.out.println(ArrayUtils.toString(degrees.toArray(new Integer[degrees.size()])));
  } finally {
    database.shutdown();
  }
}
origin: MovingBlocks/Terasology

private static List<GameInfo> getSavedGameOrRecording(Path saveOrRecordingPath) {
  SortedMap<FileTime, Path> savedGamePaths = Maps.newTreeMap(Collections.reverseOrder());
  try (DirectoryStream<Path> stream = Files.newDirectoryStream(saveOrRecordingPath)) {
    for (Path entry : stream) {
        if (!info.getTitle().isEmpty()) {
          Date date = new Date(world.getKey().toMillis());
          result.add(new GameInfo(info, date, world.getValue()));
origin: apache/incubator-druid

@Test
public void testRunTwoTiersWithExistingSegments()
         mockPeon
     ).collect(Collectors.toCollection(() -> new TreeSet<>(Collections.reverseOrder()))),
     "normal",
     Stream.of(
         mockPeon
     ).collect(Collectors.toCollection(() -> new TreeSet<>(Collections.reverseOrder())))
 CoordinatorStats stats = afterParams.getCoordinatorStats();
 Assert.assertEquals(12L, stats.getTieredStat("assignedCount", "hot"));
 Assert.assertEquals(0L, stats.getTieredStat("assignedCount", "normal"));
 Assert.assertTrue(stats.getTiers("unassignedCount").isEmpty());
 Assert.assertTrue(stats.getTiers("unassignedSize").isEmpty());
origin: apache/hbase

@Test
public void testFloat64() {
 Double[] vals =
   assertEquals("Surprising return value.",
    9, OrderedBytes.encodeFloat64(buf1, vals[i], ord));
   assertEquals("Broken test: serialization did not consume entire buffer.",
    buf1.getLength(), buf1.getPosition());
   assertEquals("Surprising serialized length.", 9, buf1.getPosition() - 1);
   assertEquals("Buffer underflow.", 0, a[0]);
   assertEquals("Buffer underflow.", 0, a[1]);
  Arrays.sort(encoded, Bytes.BYTES_COMPARATOR);
  Double[] sortedVals = Arrays.copyOf(vals, vals.length);
  if (ord == Order.ASCENDING) Arrays.sort(sortedVals);
  else Arrays.sort(sortedVals, Collections.reverseOrder());
origin: google/guava

 @Override
 public List<String> order(List<String> insertionOrder) {
  Collections.sort(insertionOrder, Collections.reverseOrder());
  return insertionOrder;
 }
}
origin: apache/incubator-druid

@Test
public void testRunRuleDoesNotExist()
         mockPeon
     ).collect(Collectors.toCollection(() -> new TreeSet<>(Collections.reverseOrder())))
java.utilCollectionsreverseOrder

Javadoc

A comparator which reverses the natural order of the elements. The Comparator that's returned is Serializable.

Popular methods of Collections

  • emptyList
    Returns the empty list (immutable). This list is serializable.This example illustrates the type-safe
  • sort
  • singletonList
    Returns an immutable list containing only the specified object. The returned list is serializable.
  • unmodifiableList
    Returns an unmodifiable view of the specified list. This method allows modules to provide users with
  • emptyMap
    Returns the empty map (immutable). This map is serializable.This example illustrates the type-safe w
  • emptySet
    Returns the empty set (immutable). This set is serializable. Unlike the like-named field, this metho
  • unmodifiableMap
    Returns an unmodifiable view of the specified map. This method allows modules to provide users with
  • singleton
    Returns an immutable set containing only the specified object. The returned set is serializable.
  • unmodifiableSet
    Returns an unmodifiable view of the specified set. This method allows modules to provide users with
  • singletonMap
    Returns an immutable map, mapping only the specified key to the specified value. The returned map is
  • addAll
    Adds all of the specified elements to the specified collection. Elements to be added may be specifie
  • reverse
    Reverses the order of the elements in the specified list. This method runs in linear time.
  • addAll,
  • reverse,
  • unmodifiableCollection,
  • shuffle,
  • enumeration,
  • list,
  • synchronizedMap,
  • synchronizedList,
  • emptyIterator

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • findViewById (Activity)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now