com.google.common.collect.Comparators Java Examples
The following examples show how to use
com.google.common.collect.Comparators.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClockManager.java From plugins with GNU General Public License v3.0 | 6 votes |
/** * Checks to ensure the timers are in the correct order. * If they are not, sort them and rebuild the clock panel * * @return whether the timer order was changed or not */ public boolean checkTimerOrder() { SortOrder sortOrder = config.sortOrder(); if (sortOrder != SortOrder.NONE) { Comparator<Timer> comparator = Comparator.comparingLong(Timer::getDisplayTime); if (sortOrder == SortOrder.DESC) { comparator = comparator.reversed(); } if (!Comparators.isInOrder(timers, comparator)) { timers.sort(comparator); SwingUtilities.invokeLater(clockTabPanel::rebuild); return true; } } return false; }
Example #2
Source File: ClockManager.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
/** * Checks to ensure the timers are in the correct order. * If they are not, sort them and rebuild the clock panel * * @return whether the timer order was changed or not */ public boolean checkTimerOrder() { SortOrder sortOrder = config.sortOrder(); if (sortOrder != SortOrder.NONE) { Comparator<Timer> comparator = Comparator.comparingLong(Timer::getDisplayTime); if (sortOrder == SortOrder.DESC) { comparator = comparator.reversed(); } if (!Comparators.isInOrder(timers, comparator)) { timers.sort(comparator); SwingUtilities.invokeLater(clockTabPanel::rebuild); return true; } } return false; }
Example #3
Source File: CriticalPathComputer.java From bazel with Apache License 2.0 | 5 votes |
/** Returns the list of slowest components. */ public List<CriticalPathComponent> getSlowestComponents() { return uniqueActions() .collect( Comparators.greatest( SLOWEST_COMPONENTS_SIZE, Comparator.comparingLong(CriticalPathComponent::getElapsedTimeNanos))); }
Example #4
Source File: CriticalPathComputer.java From bazel with Apache License 2.0 | 5 votes |
/** Returns the list of components with the largest input sizes. */ public List<CriticalPathComponent> getLargestInputSizeComponents() { return uniqueActions() .collect( Comparators.greatest( LARGEST_INPUT_SIZE_COMPONENTS_SIZE, Comparator.comparingLong( (c) -> c.getSpawnMetrics().getMaxNonDuration(0, SpawnMetrics::inputBytes)))); }
Example #5
Source File: CriticalPathComputer.java From bazel with Apache License 2.0 | 5 votes |
/** Returns the list of components using the most memory. */ public List<CriticalPathComponent> getLargestMemoryComponents() { return uniqueActions() .collect( Comparators.greatest( LARGEST_MEMORY_COMPONENTS_SIZE, Comparator.comparingLong( (c) -> c.getSpawnMetrics().getMaxNonDuration(0, SpawnMetrics::memoryEstimate)))); }
Example #6
Source File: FlowTraceHop.java From batfish with Apache License 2.0 | 5 votes |
@Override public int compareTo(FlowTraceHop o) { return Comparator.comparing(FlowTraceHop::getEdge) .thenComparing( FlowTraceHop::getTransformedFlow, Comparator.nullsFirst(Comparator.naturalOrder())) .thenComparing(FlowTraceHop::getRoutes, Comparators.lexicographical(Ordering.natural())) .thenComparing(FlowTraceHop::getFilterIn, Comparator.nullsFirst(Comparator.naturalOrder())) .thenComparing(FlowTraceHop::getFilterOut, Comparator.nullsFirst(Comparator.naturalOrder())) .compare(this, o); }
Example #7
Source File: FlowTrace.java From batfish with Apache License 2.0 | 5 votes |
@Override public int compareTo(FlowTrace rhs) { return Comparator.comparing(FlowTrace::getHops, Comparators.lexicographical(Ordering.natural())) .thenComparing(FlowTrace::getDisposition) .thenComparing(FlowTrace::getNotes, Comparator.nullsFirst(Ordering.natural())) .compare(this, rhs); }
Example #8
Source File: Layer3Edge.java From batfish with Apache License 2.0 | 5 votes |
@Override public int compareTo(Layer3Edge o) { return Comparator.comparing(Layer3Edge::getNodeInterface1) .thenComparing(Layer3Edge::getNodeInterface2) .thenComparing( Layer3Edge::getInterfaceAddresses1, Comparators.lexicographical(Ordering.natural())) .thenComparing( Layer3Edge::getInterfaceAddresses2, Comparators.lexicographical(Ordering.natural())) .compare(this, o); }
Example #9
Source File: IpWildcardSetIpSpace.java From batfish with Apache License 2.0 | 5 votes |
@Override protected int compareSameClass(IpSpace o) { return Comparator.comparing( IpWildcardSetIpSpace::getBlacklist, Comparators.lexicographical(Ordering.natural())) .thenComparing( IpWildcardSetIpSpace::getWhitelist, Comparators.lexicographical(Ordering.natural())) .compare(this, (IpWildcardSetIpSpace) o); }
Example #10
Source File: UiStateTracker.java From bazel with Apache License 2.0 | 5 votes |
private void showMnemonicHistogram(AnsiTerminalWriter terminalWriter) throws IOException { Multiset<String> mnemonicHistogram = HashMultiset.create(); for (Map.Entry<Artifact, ActionState> action : activeActions.entrySet()) { mnemonicHistogram.add(action.getValue().action.getMnemonic()); } List<Multiset.Entry<String>> sorted = mnemonicHistogram.entrySet().stream() .collect( Comparators.greatest(sampleSize, Comparator.comparingLong((e) -> e.getCount()))); for (Multiset.Entry<String> entry : sorted) { terminalWriter.newline().append(" " + entry.getElement() + " " + entry.getCount()); } }
Example #11
Source File: RoleDimensionMapping.java From batfish with Apache License 2.0 | 5 votes |
@Override public int compareTo(RoleDimensionMapping o) { return Comparator.comparing(RoleDimensionMapping::getRegex) .thenComparing( RoleDimensionMapping::getGroups, Comparator.nullsFirst(Comparators.lexicographical(Integer::compareTo))) .thenComparing( mapping -> mapping.getCanonicalRoleNames().entrySet(), Comparators.lexicographical( Comparator.comparing((Function<Entry<String, String>, String>) Entry::getKey) .thenComparing(Entry::getValue))) .compare(this, o); }
Example #12
Source File: TargetingComparatorsTest.java From bundletool with Apache License 2.0 | 5 votes |
@Test public void testMultiAbiComparator_realisticTargetingList() { ImmutableList<VariantTargeting> realisticTargetingVariants = REALISTIC_TARGETING_LIST.stream() .map(TargetingComparatorsTest::fromAbiSet) .collect(toImmutableList()); assertThat( Comparators.isInStrictOrder( realisticTargetingVariants, TargetingComparators.MULTI_ABI_COMPARATOR)) .isTrue(); }
Example #13
Source File: TargetingComparatorsTest.java From bundletool with Apache License 2.0 | 5 votes |
@Test public void testMultiAbiComparator_exhaustiveTargetingList() { ImmutableList<VariantTargeting> exhaustiveTargetingVariants = EXHAUSTIVE_TARGETING_LIST.stream() .map(TargetingComparatorsTest::fromAbiSet) .collect(toImmutableList()); assertThat( Comparators.isInStrictOrder( exhaustiveTargetingVariants, TargetingComparators.MULTI_ABI_COMPARATOR)) .isTrue(); }
Example #14
Source File: TargetingComparatorsTest.java From bundletool with Apache License 2.0 | 5 votes |
@Test public void testMultiAbiAliasComparator_realisticTargetingList() { assertThat( Comparators.isInStrictOrder( REALISTIC_TARGETING_LIST, TargetingComparators.MULTI_ABI_ALIAS_COMPARATOR)) .isTrue(); }
Example #15
Source File: TargetingComparatorsTest.java From bundletool with Apache License 2.0 | 5 votes |
@Test public void testMultiAbiAliasComparator_exhaustiveTargetingList() { assertThat( Comparators.isInStrictOrder( EXHAUSTIVE_TARGETING_LIST, TargetingComparators.MULTI_ABI_ALIAS_COMPARATOR)) .isTrue(); }
Example #16
Source File: DocumentPath.java From onos with Apache License 2.0 | 4 votes |
@Override public int compareTo(DocumentPath that) { return Comparators.lexicographical(Comparator.<String>naturalOrder()) .compare(this.pathElements, that.pathElements); }
Example #17
Source File: SortedListChecker.java From tutorials with MIT License | 4 votes |
public static boolean checkIfSortedUsingComparators(List<String> listOfStrings) { return Comparators.isInOrder(listOfStrings, Comparator.<String> naturalOrder()); }
Example #18
Source File: ZipPath.java From bundletool with Apache License 2.0 | 4 votes |
@Override public final int compareTo(ZipPath other) { return Comparators.lexicographical(Comparator.<String>naturalOrder()) .compare(getNames(), other.getNames()); }
Example #19
Source File: AsPath.java From batfish with Apache License 2.0 | 4 votes |
@Override public int compareTo(AsPath rhs) { return Comparators.lexicographical(Ordering.<AsSet>natural()).compare(_asSets, rhs._asSets); }
Example #20
Source File: AclIpSpace.java From batfish with Apache License 2.0 | 4 votes |
@Override protected int compareSameClass(IpSpace o) { return Comparators.lexicographical(Ordering.<AclIpSpaceLine>natural()) .compare(_lines, ((AclIpSpace) o)._lines); }
Example #21
Source File: DocumentPath.java From atomix with Apache License 2.0 | 4 votes |
@Override public int compareTo(DocumentPath that) { return Comparators.lexicographical(Comparator.<String>naturalOrder()) .compare(this.pathElements, that.pathElements); }
Example #22
Source File: ComparatorsExamples.java From tutorials with MIT License | 3 votes |
public static void main(String[] args) { List<Integer> integers = Arrays.asList(1, 2, 3, 4, 4, 6, 7, 8, 9, 10); boolean isInAscendingOrder = Comparators.isInOrder(integers, new AscedingOrderComparator()); System.out.println(isInAscendingOrder); }
Example #23
Source File: ComparatorsUnitTest.java From tutorials with MIT License | 3 votes |
@Test public void isInOrderTest() { List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 4, 6, 7, 8, 9, 10); boolean isInAscendingOrder = Comparators.isInOrder(numbers, new AscendingOrderComparator<Number>()); Assert.assertTrue(isInAscendingOrder); }
Example #24
Source File: ComparatorsUnitTest.java From tutorials with MIT License | 3 votes |
@Test public void isInStrictOrderTest() { List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 3, 6, 7, 8, 9, 10); boolean isInAscendingOrder = Comparators.isInOrder(numbers, new AscendingOrderComparator<Number>()); Assert.assertFalse(isInAscendingOrder); }