Skip to content

Instantly share code, notes, and snippets.

@aruld
Last active October 11, 2015 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aruld/3847475 to your computer and use it in GitHub Desktop.
Save aruld/3847475 to your computer and use it in GitHub Desktop.
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