From 0530d5c59fe8fcd814d5eaf5fb2ff8ed43f26a9c Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Mon, 11 Mar 2019 11:15:52 +0400 Subject: [PATCH] primitive maps final --- .../baeldung/primitives/PrimitiveMaps.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/libraries/src/main/java/com/baeldung/primitives/PrimitiveMaps.java b/libraries/src/main/java/com/baeldung/primitives/PrimitiveMaps.java index eaa7e308bb..89e99acfc7 100644 --- a/libraries/src/main/java/com/baeldung/primitives/PrimitiveMaps.java +++ b/libraries/src/main/java/com/baeldung/primitives/PrimitiveMaps.java @@ -21,37 +21,33 @@ public class PrimitiveMaps { private static void fastutilMap() { Int2BooleanMap int2BooleanMap = new Int2BooleanOpenHashMap(); int2BooleanMap.put(1, true); + int2BooleanMap.put(7, false); + int2BooleanMap.put(4, true); + + boolean value = int2BooleanMap.get(1); Int2BooleanSortedMap int2BooleanSorted = Int2BooleanSortedMaps.EMPTY_MAP; - int2BooleanSorted.putIfAbsent(7, true); - int2BooleanSorted.putIfAbsent(1, true); - int2BooleanSorted.putIfAbsent(4, true); } private static void coltMap() { AbstractIntDoubleMap map = new OpenIntDoubleHashMap(); map.put(1, 4.5); + double value = map.get(1); } private static void eclipseCollectionsMap() { - MutableObjectDoubleMap doubleMap = ObjectDoubleMaps.mutable.empty(); - doubleMap.put("1", 1.0d); - doubleMap.put("2", 2.0d); - - MutableObjectIntMap booleanMap = ObjectIntMaps.mutable.empty(); - booleanMap.put("ok", 1); - MutableIntIntMap mutableIntIntMap = IntIntMaps.mutable.empty(); mutableIntIntMap.addToValue(1, 1); ImmutableIntIntMap immutableIntIntMap = IntIntMaps.immutable.empty(); - MutableObjectIntMap intObject = ObjectIntMaps.mutable.empty(); - intObject.addToValue("price", 2); + MutableObjectDoubleMap dObject = ObjectDoubleMaps.mutable.empty(); + dObject.addToValue("price", 150.5); + dObject.addToValue("quality", 4.4); + dObject.addToValue("stability", 0.8); } private static void troveMap() { - double[] doubles = new double[] {1.2, 4.5, 0.3}; int[] ints = new int[] {1, 4, 0}; @@ -60,7 +56,5 @@ public class PrimitiveMaps { doubleIntMap.adjustValue(1.2, 1); doubleIntMap.adjustValue(4.5, 4); doubleIntMap.adjustValue(0.3, 0); - - System.out.println(doubleIntMap); } }