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


Java Spliterator.SORTED屬性代碼示例

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


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

示例1: assertMapCharacteristics

void assertMapCharacteristics(Map<Integer, String> m, int keyCharacteristics, int notValueCharacteristics) {
    initMap(m);

    assertCharacteristics(m.keySet(), keyCharacteristics);

    assertCharacteristics(m.values(),
                          keyCharacteristics & ~(Spliterator.DISTINCT | notValueCharacteristics));

    assertCharacteristics(m.entrySet(), keyCharacteristics);

    if ((keyCharacteristics & Spliterator.SORTED) == 0) {
        assertISEComparator(m.keySet());
        assertISEComparator(m.values());
        assertISEComparator(m.entrySet());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:SpliteratorCharacteristics.java

示例2: characteristics

@Override
public int characteristics() {
    if (beforeSplit) {
        // Concatenation loses DISTINCT and SORTED characteristics
        return aSpliterator.characteristics() & bSpliterator.characteristics()
               & ~(Spliterator.DISTINCT | Spliterator.SORTED
                   | (unsized ? Spliterator.SIZED | Spliterator.SUBSIZED : 0));
    }
    else {
        return bSpliterator.characteristics();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:Streams.java

示例3: assertSetCharacteristics

void assertSetCharacteristics(Set<Integer> s, int keyCharacteristics) {
    initSet(s);

    assertCharacteristics(s, keyCharacteristics);

    if ((keyCharacteristics & Spliterator.SORTED) == 0) {
        assertISEComparator(s);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:SpliteratorCharacteristics.java

示例4: characteristics

public int characteristics() {
    return (side == 0 ? Spliterator.SIZED : 0) |
            Spliterator.DISTINCT | Spliterator.SORTED | Spliterator.ORDERED;
}
 
開發者ID:dmcmanam,項目名稱:bbst-showdown,代碼行數:4,代碼來源:TreeMapBST.java

示例5: characteristics

public int characteristics() {
    return Spliterator.DISTINCT | Spliterator.ORDERED |
        Spliterator.SORTED;
}
 
開發者ID:dmcmanam,項目名稱:bbst-showdown,代碼行數:4,代碼來源:TreeMapRedBlack.java

示例6: characteristics

public int characteristics() {
    return Spliterator.DISTINCT | Spliterator.SORTED |
        Spliterator.ORDERED | Spliterator.CONCURRENT |
        Spliterator.NONNULL;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:ConcurrentSkipListMap.java

示例7: characteristics

@Override
public int characteristics() {
    return (s.characteristics() & ~(Spliterator.SIZED | Spliterator.SUBSIZED |
                                    Spliterator.SORTED | Spliterator.ORDERED))
           | Spliterator.DISTINCT;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:StreamSpliterators.java

示例8: filter

/** Returns a {@code Spliterator} filtered by the specified predicate. */
static <T> Spliterator<T> filter(Spliterator<T> fromSpliterator, Predicate<? super T> predicate) {
  checkNotNull(fromSpliterator);
  checkNotNull(predicate);
  class Splitr implements Spliterator<T>, Consumer<T> {
    T holder = null;

    @Override
    public void accept(T t) {
      this.holder = t;
    }

    @Override
    public boolean tryAdvance(Consumer<? super T> action) {
      while (fromSpliterator.tryAdvance(this)) {
        try {
          if (predicate.test(holder)) {
            action.accept(holder);
            return true;
          }
        } finally {
          holder = null;
        }
      }
      return false;
    }

    @Override
    public Spliterator<T> trySplit() {
      Spliterator<T> fromSplit = fromSpliterator.trySplit();
      return (fromSplit == null) ? null : filter(fromSplit, predicate);
    }

    @Override
    public long estimateSize() {
      return fromSpliterator.estimateSize() / 2;
    }

    @Override
    public Comparator<? super T> getComparator() {
      return fromSpliterator.getComparator();
    }

    @Override
    public int characteristics() {
      return fromSpliterator.characteristics()
          & (Spliterator.DISTINCT
              | Spliterator.NONNULL
              | Spliterator.ORDERED
              | Spliterator.SORTED);
    }
  }
  return new Splitr();
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:54,代碼來源:CollectSpliterators.java

示例9: fromCharacteristics

/**
 * Converts a spliterator characteristic bit set to stream flags.
 *
 * @implSpec
 * If the spliterator is naturally {@code SORTED} (the associated
 * {@code Comparator} is {@code null}) then the characteristic is converted
 * to the {@link #SORTED} flag, otherwise the characteristic is not
 * converted.
 *
 * @param spliterator the spliterator from which to obtain characteristic
 *        bit set.
 * @return the stream flags.
 */
static int fromCharacteristics(Spliterator<?> spliterator) {
    int characteristics = spliterator.characteristics();
    if ((characteristics & Spliterator.SORTED) != 0 && spliterator.getComparator() != null) {
        // Do not propagate the SORTED characteristic if it does not correspond
        // to a natural sort order
        return characteristics & SPLITERATOR_CHARACTERISTICS_MASK & ~Spliterator.SORTED;
    }
    else {
        return characteristics & SPLITERATOR_CHARACTERISTICS_MASK;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:StreamOpFlag.java


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