com.aol.cyclops.streams.operators.SkipLastOperator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cyclops-streams Show documentation
Show all versions of cyclops-streams Show documentation
Sequential Streams and Stream Utilities for Java 8
package com.aol.cyclops.streams.operators;
import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.stream.Stream;
import com.aol.cyclops.streams.StreamUtils;
public class SkipLastOperator {
Stream stream;
ArrayDeque buffer;
int skip;
public SkipLastOperator(Stream stream,int skip){
buffer = new ArrayDeque<>(skip);
this.stream = stream;
this.skip = skip;
}
public Stream skipLast(){
Iterator it = stream.iterator();
return StreamUtils.stream(new Iterator(){
boolean finished =false;
@Override
public boolean hasNext() {
while(buffer.size()
© 2015 - 2024 Weber Informatics LLC | Privacy Policy