当前位置: 首页>>代码示例>>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;未经允许,请勿转载。