當前位置: 首頁>>代碼示例>>Java>>正文


Java Comparator.reverseOrder方法代碼示例

本文整理匯總了Java中java.util.Comparator.reverseOrder方法的典型用法代碼示例。如果您正苦於以下問題:Java Comparator.reverseOrder方法的具體用法?Java Comparator.reverseOrder怎麽用?Java Comparator.reverseOrder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Comparator的用法示例。


在下文中一共展示了Comparator.reverseOrder方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MetricSampleAggregator

import java.util.Comparator; //導入方法依賴的package包/類
/**
 * Construct the metric sample aggregator.
 *
 * @param config   The load monitor configurations.
 * @param metadata The metadata of the cluster.
 */
public MetricSampleAggregator(KafkaCruiseControlConfig config,
                              Metadata metadata,
                              MetricCompletenessChecker metricCompletenessChecker) {
  _windowedAggregatedPartitionMetrics = new ConcurrentSkipListMap<>(Comparator.reverseOrder());
  // We keep twice as many the snapshot windows.
  _numSnapshots = config.getInt(KafkaCruiseControlConfig.NUM_LOAD_SNAPSHOTS_CONFIG);
  _numSnapshotsToKeep = _numSnapshots * 2;
  _snapshotWindowMs = config.getLong(KafkaCruiseControlConfig.LOAD_SNAPSHOT_WINDOW_MS_CONFIG);
  _minSamplesPerSnapshot = config.getInt(KafkaCruiseControlConfig.MIN_SAMPLES_PER_LOAD_SNAPSHOT_CONFIG);
  _activeSnapshotWindow = -1L;
  _snapshotCollectionInProgress = new AtomicInteger(0);
  _metadata = metadata;
  _metricCompletenessChecker = metricCompletenessChecker;
  _cachedAggregationResult = null;
  _cachedAggregationResultWindow = -1L;
  _aggregationResultGeneration = new AtomicLong(0);
  _latestBrokerMetrics = new ConcurrentHashMap<>();
  _identityPartitionMap = new ConcurrentHashMap<>();
}
 
開發者ID:linkedin,項目名稱:cruise-control,代碼行數:26,代碼來源:MetricSampleAggregator.java

示例2: execute

import java.util.Comparator; //導入方法依賴的package包/類
/**
 * Executes the Apriori algorithm on a specific set of transactions in order to learn
 * association rules, which specify frequent item sets.
 *
 * @param iterable An iterable, which allows to iterate the transactions, as an instance of the
 *                 type {@link Iterable}. The iterable may not be null
 * @return The rule set, which contains the association rules, which have been learned by the
 * algorithm, as an instance of the class {@link RuleSet} or an empty rule set, if no
 * association rules have been learned
 */
@NotNull
public final Output<ItemType> execute(@NotNull final Iterable<Transaction<ItemType>> iterable) {
    ensureNotNull(iterable, "The iterable may not be null");
    LOGGER.info("Starting Apriori algorithm");
    long startTime = System.currentTimeMillis();
    Map<Integer, TransactionalItemSet<ItemType>> frequentItemSets = frequentItemSetMinerTask
            .findFrequentItemSets(iterable);
    RuleSet<ItemType> ruleSet = null;

    if (configuration.isGeneratingRules()) {
        ruleSet = associationRuleGeneratorTask.generateAssociationRules(frequentItemSets);
    }

    FrequentItemSets<ItemType> sortedItemSets = new FrequentItemSets<>(
            Comparator.reverseOrder());
    frequentItemSets.values().forEach(x -> sortedItemSets.add(new ItemSet<>(x)));
    long endTime = System.currentTimeMillis();
    Output<ItemType> output = new Output<>(configuration, startTime, endTime, sortedItemSets,
            ruleSet);
    LOGGER.info("Apriori algorithm terminated after {} milliseconds", output.getRuntime());
    return output;
}
 
開發者ID:michael-rapp,項目名稱:Apriori,代碼行數:33,代碼來源:Apriori.java

示例3: testConstructor

import java.util.Comparator; //導入方法依賴的package包/類
/**
 * Tests, if all class members are set correctly by the constructor.
 */
@Test
public final void testConstructor() {
    SortedSet<ItemSet<NamedItem>> frequentItemSets = new FrequentItemSets<>(
            Comparator.reverseOrder());
    ItemSet<NamedItem> itemSet1 = new ItemSet<>();
    itemSet1.add(new NamedItem("a"));
    itemSet1.setSupport(0.5);
    ItemSet<NamedItem> itemSet2 = new ItemSet<>();
    itemSet2.add(new NamedItem("b"));
    itemSet2.setSupport(0.6);
    frequentItemSets.add(itemSet1);
    frequentItemSets.add(itemSet2);
    assertEquals(2, frequentItemSets.size());
    assertEquals(itemSet2, frequentItemSets.first());
    assertEquals(itemSet1, frequentItemSets.last());
}
 
開發者ID:michael-rapp,項目名稱:Apriori,代碼行數:20,代碼來源:FrequentItemSetsTest.java

示例4: testClone

import java.util.Comparator; //導入方法依賴的package包/類
/**
 * Tests the functionality of the clone-method.
 */
@Test
public final void testClone() {
    FrequentItemSets<NamedItem> frequentItemSets1 = new FrequentItemSets<>(
            Comparator.reverseOrder());
    ItemSet<NamedItem> itemSet1 = new ItemSet<>();
    itemSet1.add(new NamedItem("a"));
    itemSet1.setSupport(0.5);
    ItemSet<NamedItem> itemSet2 = new ItemSet<>();
    itemSet2.add(new NamedItem("b"));
    itemSet2.setSupport(0.6);
    frequentItemSets1.add(itemSet1);
    frequentItemSets1.add(itemSet2);
    FrequentItemSets<NamedItem> frequentItemSets2 = frequentItemSets1.clone();
    assertEquals(frequentItemSets1.size(), frequentItemSets2.size());
    assertEquals(frequentItemSets1.first(), frequentItemSets2.first());
    assertEquals(frequentItemSets1.last(), frequentItemSets2.last());
}
 
開發者ID:michael-rapp,項目名稱:Apriori,代碼行數:21,代碼來源:FrequentItemSetsTest.java

示例5: testFormatFrequentItemSets

import java.util.Comparator; //導入方法依賴的package包/類
/**
 * Tests the functionality of the method, which allows to create a string, which contains
 * information about frequent item sets.
 */
@Test
public final void testFormatFrequentItemSets() {
    NamedItem item1 = new NamedItem("a");
    NamedItem item2 = new NamedItem("b");
    double support1 = 0.3;
    double support2 = 0.7;
    ItemSet<NamedItem> itemSet1 = new ItemSet<>();
    itemSet1.add(item1);
    itemSet1.setSupport(support1);
    ItemSet<NamedItem> itemSet2 = new ItemSet<>();
    itemSet2.add(item2);
    itemSet2.setSupport(support2);
    FrequentItemSets<NamedItem> frequentItemSets = new FrequentItemSets<>(
            Comparator.reverseOrder());
    frequentItemSets.add(itemSet1);
    frequentItemSets.add(itemSet2);
    assertEquals(
            "[" + itemSet2 + " (support = " + support2 + "),\n" + itemSet1 + " (support = " +
                    support1 + ")]",
            FrequentItemSets.formatFrequentItemSets(frequentItemSets));
}
 
開發者ID:michael-rapp,項目名稱:Apriori,代碼行數:26,代碼來源:FrequentItemSetsTest.java

示例6: testFormatFrequentItemSetsIfEmpty

import java.util.Comparator; //導入方法依賴的package包/類
/**
 * Tests the functionality of the method, which allows to create a string, which contains
 * information about frequent item sets, if the no frequent item sets are available.
 */
@Test
public final void testFormatFrequentItemSetsIfEmpty() {
    FrequentItemSets<NamedItem> frequentItemSets = new FrequentItemSets<>(
            Comparator.reverseOrder());
    assertEquals("[]", FrequentItemSets.formatFrequentItemSets(frequentItemSets));
}
 
開發者ID:michael-rapp,項目名稱:Apriori,代碼行數:11,代碼來源:FrequentItemSetsTest.java

示例7: buildEmbed

import java.util.Comparator; //導入方法依賴的package包/類
@Override
public EmbedObject buildEmbed() {
	final EmbedBuilder builder = new EmbedBuilder();
	if (getEpicenter().equals("---")&&getDepth().equals("---")) {
		builder.withTitle("地震速報");
		final Map<SeismicIntensity, List<String>> map = new TreeMap<>(Comparator.reverseOrder());
		getDetails().forEach(detail -> detail.getCities().entrySet().forEach(city -> {
			List<String> list = map.get(city.getKey());
			if (list==null)
				map.put(city.getKey(), list = new ArrayList<>());
			list.addAll(city.getValue());
		}));
		map.entrySet().forEach(entry -> builder.appendField(entry.getKey().toString(), String.join("  ", entry.getValue()), false));
	} else {
		builder.withTitle("地震情報");
		builder.appendField("震央", getEpicenter(), true);
		if (!getDepth().equals("---"))
			builder.appendField("深さ", getDepth(), true);
		if (getMagnitude()>0f)
			builder.appendField("マグニチュード", String.valueOf(getMagnitude()), true);
		getMaxIntensity().ifPresent(intensity -> builder.appendField("最大震度", intensity.getSimple(), false));
	}
	builder.appendField("情報", getInfo(), true);

	getMaxIntensity().ifPresent(intensity -> builder.withColor(intensity.getColor()));
	builder.withTimestamp(getAnnounceTime().getTime());
	getImageUrl().ifPresent(url -> builder.withImage(url));

	builder.withFooterText("地震情報 - Yahoo!天気・災害");
	builder.withUrl(getUrl());
	return builder.build();
}
 
開發者ID:Team-Fruit,項目名稱:EEWBot,代碼行數:33,代碼來源:QuakeInfo.java

示例8: testReverseComparator

import java.util.Comparator; //導入方法依賴的package包/類
public void testReverseComparator() {
    Comparator<String> cmpr = Comparator.reverseOrder();
    Comparator<String> cmp = cmpr.reversed();

    assertEquals(cmp.reversed(), cmpr);
    assertEquals(0, cmp.compare("a", "a"));
    assertEquals(0, cmpr.compare("a", "a"));
    assertTrue(cmp.compare("a", "b") < 0);
    assertTrue(cmpr.compare("a", "b") > 0);
    assertTrue(cmp.compare("b", "a") > 0);
    assertTrue(cmpr.compare("b", "a") < 0);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:BasicTest.java

示例9: createCourseComparator

import java.util.Comparator; //導入方法依賴的package包/類
private Comparator<Course> createCourseComparator (String sortType) {
    if(sortType.equalsIgnoreCase("descending")) {
        return Comparator.reverseOrder();
    } else if (sortType.equalsIgnoreCase("ascending")) {
        return Comparator.naturalOrder();
    } else {
        throw  new InvalidInputException(this.getInput());
    }
}
 
開發者ID:kostovhg,項目名稱:SoftUni,代碼行數:10,代碼來源:DisplayCommand.java

示例10: MetricCompletenessChecker

import java.util.Comparator; //導入方法依賴的package包/類
public MetricCompletenessChecker(int maxNumSnapshots) {
  _validPartitionsPerTopicByWindows = new ConcurrentSkipListMap<>(Comparator.reverseOrder());
  _validPartitionsByWindows = new TreeMap<>(Comparator.reverseOrder());
  _modelGeneration = null;
  _maxNumSnapshots = maxNumSnapshots;
}
 
開發者ID:linkedin,項目名稱:cruise-control,代碼行數:7,代碼來源:MetricCompletenessChecker.java

示例11: IEXOrderBook

import java.util.Comparator; //導入方法依賴的package包/類
public IEXOrderBook(final String symbol) {
    this.symbol = symbol;
    this.bidOffers = new TreeMap<>(Comparator.reverseOrder());
    this.askOffers = new TreeMap<>();
}
 
開發者ID:WojciechZankowski,項目名稱:iextrading4j-book,代碼行數:6,代碼來源:IEXOrderBook.java


注:本文中的java.util.Comparator.reverseOrder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。