本文整理汇总了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;
}
示例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));
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
};
}
示例7: entrySpliterator
import java.util.Spliterators; //导入方法依赖的package包/类
Spliterator<Entry<K, V>> entrySpliterator() {
return Spliterators.spliterator(
entryIterator(), size(), (this instanceof SetMultimap) ? Spliterator.DISTINCT : 0);
}
示例8: spliterator
import java.util.Spliterators; //导入方法依赖的package包/类
@Override
public Spliterator<E> spliterator() {
return Spliterators.spliterator(array, SPLITERATOR_CHARACTERISTICS);
}
示例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);
}
示例10: spliterator
import java.util.Spliterators; //导入方法依赖的package包/类
@Override
public Spliterator<E> spliterator() {
return Spliterators.spliterator(this, SPLITERATOR_CHARACTERISTICS);
}
示例11: spliterator
import java.util.Spliterators; //导入方法依赖的package包/类
@Override
public Spliterator<E> spliterator() {
return Spliterators.spliterator(elements, SPLITERATOR_CHARACTERISTICS);
}
示例12: spliterator
import java.util.Spliterators; //导入方法依赖的package包/类
@Override
public Spliterator<Entry<K, V>> spliterator() {
return Spliterators.spliterator(entries, ImmutableSet.SPLITERATOR_CHARACTERISTICS);
}
示例13: spliterator
import java.util.Spliterators; //导入方法依赖的package包/类
private Spliterator.OfInt spliterator() {
return Spliterators.spliterator(array, start, end, Spliterator.IMMUTABLE | Spliterator.ORDERED);
}
示例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);
}
示例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);
}