11package com .baeldung .pcollections ;
22
33import org .junit .Test ;
4- import org .pcollections .*;
4+ import org .pcollections .HashPMap ;
5+ import org .pcollections .HashTreePMap ;
6+ import org .pcollections .HashTreePSet ;
7+ import org .pcollections .MapPSet ;
8+ import org .pcollections .PVector ;
9+ import org .pcollections .TreePVector ;
510
611import java .util .Arrays ;
712import java .util .HashMap ;
@@ -27,7 +32,7 @@ public void givenKeyValue_whenSingleton_thenCreateNonEmptyHashPMap() {
2732
2833 @ Test
2934 public void givenExistingHashMap_whenFrom_thenCreateHashPMap () {
30- Map map = new HashMap ();
35+ Map < String , String > map = new HashMap <> ();
3136 map .put ("mkey1" , "mval1" );
3237 map .put ("mkey2" , "mval2" );
3338
@@ -41,7 +46,7 @@ public void whenHashPMapMethods_thenPerformOperations() {
4146 HashPMap <String , String > pmap = HashTreePMap .empty ();
4247 HashPMap <String , String > pmap0 = pmap .plus ("key1" , "value1" );
4348
44- Map map = new HashMap ();
49+ Map < String , String > map = new HashMap <> ();
4550 map .put ("key2" , "val2" );
4651 map .put ("key3" , "val3" );
4752
@@ -57,30 +62,32 @@ public void whenHashPMapMethods_thenPerformOperations() {
5762
5863 @ Test
5964 public void whenTreePVectorMethods_thenPerformOperations () {
60- TreePVector pVector = TreePVector .empty ();
65+ TreePVector <String > pVector = TreePVector .empty ();
66+
67+ TreePVector <String > pV1 = pVector .plus ("e1" );
68+ TreePVector <String > pV2 = pV1 .plusAll (Arrays .asList ("e2" , "e3" , "e4" ));
6169
62- TreePVector pV1 = pVector .plus ("e1" );
63- TreePVector pV2 = pV1 .plusAll (Arrays .asList ("e2" , "e3" , "e4" ));
6470 assertEquals (1 , pV1 .size ());
6571 assertEquals (4 , pV2 .size ());
6672
67- TreePVector pV3 = pV2 .minus ("e1" );
68- TreePVector pV4 = pV3 .minusAll (Arrays .asList ("e2" , "e3" , "e4" ));
73+ TreePVector <String > pV3 = pV2 .minus ("e1" );
74+ TreePVector <String > pV4 = pV3 .minusAll (Arrays .asList ("e2" , "e3" , "e4" ));
75+
6976 assertEquals (pV3 .size (), 3 );
7077 assertEquals (pV4 .size (), 0 );
7178
72- TreePVector pSub = pV2 .subList (0 , 2 );
79+ TreePVector < String > pSub = pV2 .subList (0 , 2 );
7380 assertTrue (pSub .contains ("e1" ) && pSub .contains ("e2" ));
7481
75- TreePVector pVW = ( TreePVector ) pV2 .with (0 , "e10" );
82+ PVector < String > pVW = pV2 .with (0 , "e10" );
7683 assertEquals (pVW .get (0 ), "e10" );
7784 }
7885
7986 @ Test
8087 public void whenMapPSetMethods_thenPerformOperations () {
8188
8289 MapPSet pSet = HashTreePSet .empty ()
83- .plusAll (Arrays .asList ("e1" ,"e2" ,"e3" ,"e4" ));
90+ .plusAll (Arrays .asList ("e1" , "e2" , "e3" , "e4" ));
8491 assertEquals (pSet .size (), 4 );
8592
8693 MapPSet pSet1 = pSet .minus ("e4" );
0 commit comments