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


Java Spliterators.spliterator方法代碼示例

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


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

示例1: trySplit

import java.util.Spliterators; //導入方法依賴的package包/類
@Override
public Spliterator<E> trySplit() {
  Node<E> p;
  int s = getEst();
  if (s > 1 && (p = current) != null) {
    int n = batch + BATCH_UNIT;
    if (n > s) {
      n = s;
    }
    if (n > MAX_BATCH) {
      n = MAX_BATCH;
    }
    Object[] a = new Object[n];
    int j = 0;
    do {
      a[j++] = p.item;
    } while ((p = p.next) != null && j < n);
    current = p;
    batch = j;
    est = s - j;
    return Spliterators.spliterator(a, 0, j, Spliterator.ORDERED);
  }
  return null;
}
 
開發者ID:XDean,項目名稱:Java-EX,代碼行數:25,代碼來源:LinkedList.java

示例2: trySplit

import java.util.Spliterators; //導入方法依賴的package包/類
public Spliterator<E> trySplit() {
    Node<E> p, q;
    if ((p = current()) == null || (q = p.next) == null)
        return null;
    int i = 0, n = batch = Math.min(batch + 1, MAX_BATCH);
    Object[] a = null;
    do {
        final E e;
        if ((e = p.item) != null) {
            if (a == null)
                a = new Object[n];
            a[i++] = e;
        }
        if (p == (p = q))
            p = first();
    } while (p != null && (q = p.next) != null && i < n);
    setCurrent(p);
    return (i == 0) ? null :
        Spliterators.spliterator(a, 0, i, (Spliterator.ORDERED |
                                           Spliterator.NONNULL |
                                           Spliterator.CONCURRENT));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:ConcurrentLinkedDeque.java

示例3: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
public Spliterator<E> spliterator() {
    synchronized (l.lock) {
        return Spliterators.spliterator(
                getArrayChecked(), offset, offset + size,
                Spliterator.IMMUTABLE | Spliterator.ORDERED);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:CopyOnWriteArrayList.java

示例4: trySplit

import java.util.Spliterators; //導入方法依賴的package包/類
public Spliterator<E> trySplit() {
    Node p;
    final LinkedTransferQueue<E> q = this.queue;
    int b = batch;
    int n = (b <= 0) ? 1 : (b >= MAX_BATCH) ? MAX_BATCH : b + 1;
    if (!exhausted &&
        ((p = current) != null || (p = q.firstDataNode()) != null) &&
        p.next != null) {
        Object[] a = new Object[n];
        int i = 0;
        do {
            Object e = p.item;
            if (e != p && (a[i] = e) != null)
                ++i;
            if (p == (p = p.next))
                p = q.firstDataNode();
        } while (p != null && i < n && p.isData);
        if ((current = p) == null)
            exhausted = true;
        if (i > 0) {
            batch = i;
            return Spliterators.spliterator
                (a, 0, i, Spliterator.ORDERED | Spliterator.NONNULL |
                 Spliterator.CONCURRENT);
        }
    }
    return null;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:29,代碼來源:LinkedTransferQueue.java

示例5: trySplit

import java.util.Spliterators; //導入方法依賴的package包/類
public Spliterator<E> trySplit() {
    Node<E> h;
    final LinkedBlockingQueue<E> q = this.queue;
    int b = batch;
    int n = (b <= 0) ? 1 : (b >= MAX_BATCH) ? MAX_BATCH : b + 1;
    if (!exhausted &&
        ((h = current) != null || (h = q.head.next) != null) &&
        h.next != null) {
        Object[] a = new Object[n];
        int i = 0;
        Node<E> p = current;
        q.fullyLock();
        try {
            if (p != null || (p = q.head.next) != null) {
                do {
                    if ((a[i] = p.item) != null)
                        ++i;
                } while ((p = p.next) != null && i < n);
            }
        } finally {
            q.fullyUnlock();
        }
        if ((current = p) == null) {
            est = 0L;
            exhausted = true;
        }
        else if ((est -= i) < 0L)
            est = 0L;
        if (i > 0) {
            batch = i;
            return Spliterators.spliterator
                (a, 0, i, Spliterator.ORDERED | Spliterator.NONNULL |
                 Spliterator.CONCURRENT);
        }
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:38,代碼來源:LinkedBlockingQueue.java

示例6: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public Spliterator<Item> spliterator() {
    return new Spliterator<Item>() {
        int currentElementIdx = 0;

        /**
         * {@inheritDoc}
         */
        @Override
        public boolean tryAdvance(Consumer<? super Item> action) {
            if (null == action) {
                throw new NullPointerException();
            }
            if (currentElementIdx < topPosition) {
                action.accept(internalArray[currentElementIdx]);
                currentElementIdx++;
                return true;
            } else {
                return false;
            }
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public Spliterator<Item> trySplit() {
            return Spliterators.spliterator(
                    Arrays.copyOfRange(internalArray, currentElementIdx, internalArray.length)
                    , IMMUTABLE | SIZED
            );
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public long estimateSize() {
            return size() - currentElementIdx;
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public int characteristics() {
            return IMMUTABLE | SIZED;
        }
    };
}
 
開發者ID:javatlacati,項目名稱:datastrructureskotlin,代碼行數:54,代碼來源:ArrayBasedBag.java

示例7: entrySpliterator

import java.util.Spliterators; //導入方法依賴的package包/類
Spliterator<Entry<K, V>> entrySpliterator() {
  return Spliterators.spliterator(
      entryIterator(), size(), (this instanceof SetMultimap) ? Spliterator.DISTINCT : 0);
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:5,代碼來源:AbstractMultimap.java

示例8: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
@Override
public Spliterator<E> spliterator() {
  return Spliterators.spliterator(array, SPLITERATOR_CHARACTERISTICS);
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:5,代碼來源:RegularImmutableList.java

示例9: entrySpliterator

import java.util.Spliterators; //導入方法依賴的package包/類
Spliterator<Entry<K, V>> entrySpliterator() {
  return Spliterators.spliterator(
      entryIterator(),
      size(),
      Spliterator.DISTINCT | Spliterator.NONNULL | Spliterator.IMMUTABLE | Spliterator.ORDERED);
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:7,代碼來源:ImmutableMap.java

示例10: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
@Override
public Spliterator<E> spliterator() {
  return Spliterators.spliterator(this, SPLITERATOR_CHARACTERISTICS);
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:5,代碼來源:ImmutableCollection.java

示例11: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
@Override
public Spliterator<E> spliterator() {
  return Spliterators.spliterator(elements, SPLITERATOR_CHARACTERISTICS);
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:5,代碼來源:RegularImmutableSet.java

示例12: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
@Override
public Spliterator<Entry<K, V>> spliterator() {
  return Spliterators.spliterator(entries, ImmutableSet.SPLITERATOR_CHARACTERISTICS);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:5,代碼來源:ImmutableMapEntrySet.java

示例13: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
private Spliterator.OfInt spliterator() {
  return Spliterators.spliterator(array, start, end, Spliterator.IMMUTABLE | Spliterator.ORDERED);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:4,代碼來源:ImmutableIntArray.java

示例14: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
/**
 * Returns a Spliterator over entries in this object.
 * A default implementation is provided which is equivalent to the
 * default implementation on the Collection interface.
 * @return a Spliterator over entries in this object
 */
public default Spliterator<Entry> spliterator() {
    return Spliterators.spliterator(this.iterator(), this.size(), 0);
}
 
開發者ID:awslabs,項目名稱:swage,代碼行數:10,代碼來源:TypedMap.java

示例15: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
/**
 * Returns a {@link Spliterator} over the elements in this queue.
 *
 * <p>The returned spliterator is
 * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
 *
 * <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT},
 * {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}.
 *
 * @implNote
 * The {@code Spliterator} implements {@code trySplit} to permit limited
 * parallelism.
 *
 * @return a {@code Spliterator} over the elements in this queue
 * @since 1.8
 */
public Spliterator<E> spliterator() {
    return Spliterators.spliterator
        (this, Spliterator.ORDERED | Spliterator.NONNULL |
         Spliterator.CONCURRENT);
}
 
開發者ID:roger-dv,項目名稱:spartan-jasync,代碼行數:22,代碼來源:ArrayBlockingQueue.java


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