com.annimon.stream.operator.LongSorted Maven / Gradle / Ivy
The newest version!
package com.annimon.stream.operator;
import com.annimon.stream.internal.Operators;
import com.annimon.stream.iterator.PrimitiveExtIterator;
import com.annimon.stream.iterator.PrimitiveIterator;
import java.util.Arrays;
public class LongSorted extends PrimitiveExtIterator.OfLong {
private final PrimitiveIterator.OfLong iterator;
private int index;
private long[] array;
public LongSorted(PrimitiveIterator.OfLong iterator) {
this.iterator = iterator;
index = 0;
}
@Override
protected void nextIteration() {
if (!isInit) {
array = Operators.toLongArray(iterator);
Arrays.sort(array);
}
hasNext = index < array.length;
if (hasNext) {
next = array[index++];
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy