All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aol.cyclops.streams.operators.SkipLastOperator Maven / Gradle / Ivy

There is a newer version: 7.3.1
Show newest version
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