Skip to content

Commit a60d2fa

Browse files
authored
Merge pull request eugenp#6183 from MherBaghinyan/BAEL-2564
Bael 2564
2 parents e37e543 + ca98fbb commit a60d2fa

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

core-java-collections-list/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@
3636
<version>${lombok.version}</version>
3737
<scope>provided</scope>
3838
</dependency>
39+
40+
<dependency>
41+
<groupId>net.sf.trove4j</groupId>
42+
<artifactId>trove4j</artifactId>
43+
<version>3.0.2</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>it.unimi.dsi</groupId>
47+
<artifactId>fastutil</artifactId>
48+
<version>8.1.0</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>colt</groupId>
52+
<artifactId>colt</artifactId>
53+
<version>1.2.0</version>
54+
</dependency>
3955
</dependencies>
4056

4157
<properties>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.baeldung.list.primitive;
2+
3+
import com.google.common.primitives.ImmutableIntArray;
4+
import com.google.common.primitives.Ints;
5+
import gnu.trove.list.array.TIntArrayList;
6+
import it.unimi.dsi.fastutil.ints.IntArrayList;
7+
8+
import java.util.Arrays;
9+
import java.util.List;
10+
import java.util.OptionalDouble;
11+
import java.util.function.IntPredicate;
12+
import java.util.stream.IntStream;
13+
14+
public class PrimitiveCollections {
15+
16+
public static void main(String[] args) {
17+
18+
int[] primitives = new int[] {5, 10, 0, 2, -8};
19+
20+
guavaPrimitives(primitives);
21+
22+
intStream(primitives);
23+
24+
TIntArrayList tList = new TIntArrayList(primitives);
25+
26+
cern.colt.list.IntArrayList coltList = new cern.colt.list.IntArrayList(primitives);
27+
28+
IntArrayList fastUtilList = new IntArrayList(primitives);
29+
30+
System.out.println(tList);
31+
32+
System.out.println(coltList);
33+
34+
System.out.println(fastUtilList);
35+
}
36+
37+
private static void intStream(int[] primitives) {
38+
39+
IntStream stream = IntStream.of(5, 10, 0, 2, -8);
40+
41+
IntStream newStream = IntStream.of(primitives);
42+
43+
OptionalDouble average = stream.filter(i -> i > 0).average();
44+
}
45+
46+
47+
private static void guavaPrimitives(int[] primitives) {
48+
49+
ImmutableIntArray immutableIntArray = ImmutableIntArray.builder().addAll(primitives).build();
50+
System.out.println(immutableIntArray);
51+
}
52+
}

0 commit comments

Comments
 (0)