Merge pull request #6183 from MherBaghinyan/BAEL-2564

Bael 2564
This commit is contained in:
Eric Martin 2019-02-03 00:30:48 -06:00 committed by GitHub
commit a60d2fa0f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 0 deletions

View File

@ -36,6 +36,22 @@
<version>${lombok.version}</version> <version>${lombok.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove4j</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.1.0</version>
</dependency>
<dependency>
<groupId>colt</groupId>
<artifactId>colt</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>

View File

@ -0,0 +1,52 @@
package com.baeldung.list.primitive;
import com.google.common.primitives.ImmutableIntArray;
import com.google.common.primitives.Ints;
import gnu.trove.list.array.TIntArrayList;
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, -8};
guavaPrimitives(primitives);
intStream(primitives);
TIntArrayList tList = new TIntArrayList(primitives);
cern.colt.list.IntArrayList coltList = new cern.colt.list.IntArrayList(primitives);
IntArrayList fastUtilList = new IntArrayList(primitives);
System.out.println(tList);
System.out.println(coltList);
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) {
ImmutableIntArray immutableIntArray = ImmutableIntArray.builder().addAll(primitives).build();
System.out.println(immutableIntArray);
}
}