Skip to content

Commit

Permalink
primitive maps final
Browse files Browse the repository at this point in the history
  • Loading branch information
MherBaghinyan committed Mar 11, 2019
1 parent 5ac596b commit 0530d5c
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions libraries/src/main/java/com/baeldung/primitives/PrimitiveMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,33 @@ public static void main(String[] args) {
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<String> doubleMap = ObjectDoubleMaps.mutable.empty();
doubleMap.put("1", 1.0d);
doubleMap.put("2", 2.0d);

MutableObjectIntMap<String> booleanMap = ObjectIntMaps.mutable.empty();
booleanMap.put("ok", 1);

MutableIntIntMap mutableIntIntMap = IntIntMaps.mutable.empty();
mutableIntIntMap.addToValue(1, 1);

ImmutableIntIntMap immutableIntIntMap = IntIntMaps.immutable.empty();

MutableObjectIntMap<String> intObject = ObjectIntMaps.mutable.empty();
intObject.addToValue("price", 2);
MutableObjectDoubleMap<String> 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};

Expand All @@ -60,7 +56,5 @@ private static void troveMap() {
doubleIntMap.adjustValue(1.2, 1);
doubleIntMap.adjustValue(4.5, 4);
doubleIntMap.adjustValue(0.3, 0);

System.out.println(doubleIntMap);
}
}

0 comments on commit 0530d5c

Please sign in to comment.