/* public V get(Object oKey) { K key = null; try { key = (K)oKey; } catch (Exception ex) { throwRuntimeException(new Exception("Can't do get in MapArray. Key have wrong type")); } return get(key); }*/ public V get(K key) { Pair<K, V> first = null; try { first = LinqUtils.first(pairs, pair -> pair.key.equals(key)); } catch (Exception ignore) { } return (first != null) ? first.value : null; }
@Override public String toString() { return print(LinqUtils.select(pairs, pair -> pair.key + ":" + pair.value)); }
public void removeAllValues(V value) { LinqUtils.where(pairs, p -> p.value.equals(value)).forEach(pairs::remove); }
public void removeByKey(K key) { pairs.remove(LinqUtils.firstIndex(pairs, pair -> pair.key.equals(key))); }
public Collection<V> values(Function<V, Boolean> condition) { return LinqUtils.where(values(), condition); }
public Collection<V> values() { return LinqUtils.select(pairs, pair -> pair.value); }
public Collection<K> keys() { return LinqUtils.select(pairs, pair -> pair.key); }