Skip to content

Instantly share code, notes, and snippets.

@aruld

aruld/MyList.java

Last active Oct 11, 2015
Embed
What would you like to do?
Updated to compile with the latest lambda build 94.
package java.util.stream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
public class MyList<E> extends ArrayList<E> {
public MyList(int initialCapacity) {
super(initialCapacity);
}
public MyList() {
super();
}
public MyList(Collection<? extends E> c) {
super(c);
}
@Override
public MyStream<E> stream() {
return new MyReferencePipeline<>(Arrays.spliterator((E[]) this.toArray(), 0, this.size()), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED, false);
}
@Override
public Stream<E> parallelStream() {
return new MyReferencePipeline<>(Arrays.spliterator((E[]) this.toArray(), 0, this.size()), StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED, true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment