Added Stream Api

This commit is contained in:
mherbaghinyan 2019-01-31 16:18:59 +04:00
parent d944b67c29
commit ca98fbb706
1 changed files with 15 additions and 1 deletions

View File

@ -7,15 +7,20 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.OptionalDouble;
import java.util.function.IntPredicate;
import java.util.stream.IntStream;
public class PrimitiveCollections {
public static void main(String[] args) {
int[] primitives = new int[] {5, 10, 0, 2};
int[] primitives = new int[] {5, 10, 0, 2, -8};
guavaPrimitives(primitives);
intStream(primitives);
TIntArrayList tList = new TIntArrayList(primitives);
cern.colt.list.IntArrayList coltList = new cern.colt.list.IntArrayList(primitives);
@ -29,6 +34,15 @@ public class PrimitiveCollections {
System.out.println(fastUtilList);
}
private static void intStream(int[] primitives) {
IntStream stream = IntStream.of(5, 10, 0, 2, -8);
IntStream newStream = IntStream.of(primitives);
OptionalDouble average = stream.filter(i -> i > 0).average();
}
private static void guavaPrimitives(int[] primitives) {