当前位置: 首页>>代码示例>>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;未经允许,请勿转载。