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


Java Ordering.natural方法代碼示例

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


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

示例1: testImmutableSortedSet

import com.google.common.collect.Ordering; //導入方法依賴的package包/類
@Test
public void testImmutableSortedSet() {
  ImmutableSortedSet<String> set = newSet();
  assertEquals(3, set.size());
  assertFalse(set.isEmpty());
  assertEquals("bar", set.getMinEntry());
  assertEquals("foo", set.getMaxEntry());
  assertEquals("bar", set.getPredecessorEntry("baz"));
  assertTrue(set.contains("foo"));
  assertFalse(set.contains("not found"));
  assertEquals(set.hashCode(), set.hashCode());
  assertEquals(set, set);

  ImmutableSortedSet<String> set2 = newSet();
  assertEquals(set.hashCode(), set2.hashCode());
  assertEquals(set, set2);

  List<String> original = new ArrayList<>();
  Collections.addAll(original, "abc", "mno", "pqr");
  set2 = new ImmutableSortedSet<>(original, Ordering.<String>natural());
  assertNotEquals(set.hashCode(), set2.hashCode());
  assertNotEquals(set, set2);
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:24,代碼來源:ImmutableSortedSetTest.java

示例2: OrderingByPosition

import com.google.common.collect.Ordering; //導入方法依賴的package包/類
private OrderingByPosition (int position, boolean reverse, @Nullable Boolean nullFirst) {
    this.position = position;

    // note, that we are reverse for the queue so this conditional is by intent
    Ordering<Comparable> ordering;
    nullFirst = nullFirst != null ? !nullFirst : null; // swap because queue is reverse
    if (reverse) {
        ordering = Ordering.natural();
        if (nullFirst == null || !nullFirst) {
            ordering = ordering.nullsLast();
        } else {
            ordering = ordering.nullsFirst();
        }
    } else {
        ordering = Ordering.natural().reverse();
        if (nullFirst == null || nullFirst) {
            ordering = ordering.nullsFirst();
        } else {
            ordering = ordering.nullsLast();
        }
    }
    this.ordering = ordering;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:24,代碼來源:OrderingByPosition.java

示例3: isNaturalComparator

import com.google.common.collect.Ordering; //導入方法依賴的package包/類
private static boolean isNaturalComparator(Comparator<?> a)
{
    return a == null || a == Comparator.naturalOrder() || a == Ordering.natural();
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:5,代碼來源:BTree.java

示例4: of

import com.google.common.collect.Ordering; //導入方法依賴的package包/類
public static <V extends Comparable<V>> BTreeSet<V> of(Collection<V> sortedValues)
{
    return new BTreeSet<>(BTree.build(sortedValues, UpdateFunction.<V>noOp()), Ordering.<V>natural());
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:5,代碼來源:BTreeSet.java

示例5: newSet

import com.google.common.collect.Ordering; //導入方法依賴的package包/類
private ImmutableSortedSet<String> newSet() {
  List<String> original = new ArrayList<>();
  Collections.addAll(original, "foo", "bar", "baz");
  return new ImmutableSortedSet<>(original, Ordering.<String>natural());
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:6,代碼來源:ImmutableSortedSetTest.java

示例6: natural

import com.google.common.collect.Ordering; //導入方法依賴的package包/類
/**
 * Returns an instance which specifies that the natural ordering of the elements is guaranteed.
 */
public static <S extends Comparable<? super S>> ElementOrder<S> natural() {
  return new ElementOrder<S>(Type.SORTED, Ordering.<S>natural());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:7,代碼來源:ElementOrder.java


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