Ejemplo n.º 1
0
 public java.util.Map<K, V> toMap() {
   final java.util.HashMap<K, V> result = new java.util.HashMap<>();
   for (K key : keys()) {
     result.put(key, get(key).some());
   }
   return result;
 }
Ejemplo n.º 2
0
  /**
   * Returns all key entries in this hash map.
   *
   * @return All key entries in this hash map.
   */
  public List<K> keys() {
    final List.Buffer<K> b = new List.Buffer<>();

    for (final Key k : m.keySet()) {
      b.snoc(k.k);
    }

    return b.toList();
  }
Ejemplo n.º 3
0
 /**
  * Deletes the entry in the hash map that corresponds to the given key and returns any associated
  * value.
  *
  * @param k The key to delete from this hash map.
  * @return The value that was associated with the given key, if there was one.
  */
 public Option<V> getDelete(final K k) {
   return fromNull(m.remove(new Key(k)));
 }
Ejemplo n.º 4
0
 /**
  * Deletes the entry in the hash map that corresponds to the given key.
  *
  * @param k The key to delete from this hash map.
  */
 public void delete(final K k) {
   m.remove(new Key(k));
 }
Ejemplo n.º 5
0
 /**
  * Inserts the given key and value association into the hash map.
  *
  * @param k The key to insert.
  * @param v The value to insert.
  */
 public void set(final K k, final V v) {
   if (v != null) {
     m.put(new Key(k), v);
   }
 }
Ejemplo n.º 6
0
 /**
  * Returns the number of entries in this hash map.
  *
  * @return The number of entries in this hash map.
  */
 public int size() {
   return m.size();
 }
Ejemplo n.º 7
0
 /**
  * Determines if this hash map has any entries.
  *
  * @return <code>true</code> if this hash map has no entries, <code>false</code> otherwise.
  */
 public boolean isEmpty() {
   return m.isEmpty();
 }
Ejemplo n.º 8
0
 /**
  * Returns all values in this hash map.
  *
  * @return All values in this hash map.
  */
 public List<V> values() {
   return iterableList(m.values());
 }
Ejemplo n.º 9
0
 /**
  * Determines if the given key value exists in this hash map.
  *
  * @param k The key value to look for in this hash map.
  * @return <code>true</code> if this hash map contains the given key, <code>false</code>
  *     otherwise.
  */
 public boolean contains(final K k) {
   return m.containsKey(new Key(k));
 }
Ejemplo n.º 10
0
 /** Clear all entries from this hash map. */
 public void clear() {
   m.clear();
 }
Ejemplo n.º 11
0
 /**
  * Returns a potential value that the given key maps to.
  *
  * @param k The key to look up in the hash map.
  * @return A potential value for the given key.
  */
 public Option<V> get(final K k) {
   return fromNull(m.get(new Key(k)));
 }