Example #1
0
 /**
  * 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());
   }
 }
Example #2
0
  /**
   * 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);
  }
Example #3
0
 /**
  * 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();
 }
Example #4
0
 /**
  * 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();
 }
Example #5
0
 /**
  * Is map empty or not.
  *
  * @return boolean indicating empty map or not
  */
 public boolean isEmpty() {
   return map.isEmpty();
 }
Example #6
0
 /**
  * Return the number of unique entries in the map.
  *
  * @return number of unique entries in the map.
  */
 public int size() {
   return map.size();
 }
Example #7
0
 /**
  * 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());
   }
 }
Example #8
0
  /**
   * 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);
  }
Example #9
0
  /**
   * 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);
  }