/** * Iterate over the entries of the map * * @param consumer to apply to each entry in the map */ public void forEach(final EntryConsumer<V> consumer) { for (Map.Entry<Long, V> entry : map.entrySet()) { Long compoundKey = entry.getKey(); final int keyPartA = (int) (compoundKey >>> 32); final int keyPartB = (int) (compoundKey & 0xFFFFFFFFL); consumer.accept(keyPartA, keyPartB, entry.getValue()); } }
/** * Put a value into the map. * * @param keyPartA for the key * @param keyPartB for the key * @param value to put into the map * @return the previous value if found otherwise null */ public V put(final int keyPartA, final int keyPartB, final V value) { final long key = compoundKey(keyPartA, keyPartB); return map.put(key, value); }
/** * Get the load factor beyond which the map will increase size. * * @return load factor for when the map should increase size. */ public double loadFactor() { return map.loadFactor(); }
/** * Get the total capacity for the map to which the load factor with be a fraction of. * * @return the total capacity for the map. */ public int capacity() { return map.capacity(); }
/** * Is map empty or not. * * @return boolean indicating empty map or not */ public boolean isEmpty() { return map.isEmpty(); }
/** * Return the number of unique entries in the map. * * @return number of unique entries in the map. */ public int size() { return map.size(); }
/** * Iterate over the values in the map * * @param consumer to apply to each value in the map */ public void forEach(final Consumer<V> consumer) { for (Map.Entry<Long, V> entry : map.entrySet()) { consumer.accept(entry.getValue()); } }
/** * Remove a value from the map and return the value. * * @param keyPartA for the key * @param keyPartB for the key * @return the previous value if found otherwise null */ public V remove(final int keyPartA, final int keyPartB) { final long key = compoundKey(keyPartA, keyPartB); return map.remove(key); }
/** * Retrieve a value from the map. * * @param keyPartA for the key * @param keyPartB for the key * @return value matching the key if found or null if not found. */ public V get(final int keyPartA, final int keyPartB) { final long key = compoundKey(keyPartA, keyPartB); return map.get(key); }