com.google.common.collect.Comparators#isInOrder ( )源码实例Demo

下面列出了com.google.common.collect.Comparators#isInOrder ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: plugins   文件: ClockManager.java
/**
 * 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;
}
 
源代码2 项目: runelite   文件: ClockManager.java
/**
 * 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;
}
 
源代码3 项目: tutorials   文件: SortedListChecker.java
public static boolean checkIfSortedUsingComparators(List<String> listOfStrings) {
    return Comparators.isInOrder(listOfStrings, Comparator.<String> naturalOrder());
}
 
源代码4 项目: tutorials   文件: ComparatorsExamples.java
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);

    }
 
源代码5 项目: tutorials   文件: ComparatorsUnitTest.java
@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);
}
 
源代码6 项目: tutorials   文件: ComparatorsUnitTest.java
@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);
}
 
 同类方法