Example #1
0
 /*
 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;
 }
Example #2
0
 @Override
 public String toString() {
   return print(LinqUtils.select(pairs, pair -> pair.key + ":" + pair.value));
 }
Example #3
0
 public void removeAllValues(V value) {
   LinqUtils.where(pairs, p -> p.value.equals(value)).forEach(pairs::remove);
 }
Example #4
0
 public void removeByKey(K key) {
   pairs.remove(LinqUtils.firstIndex(pairs, pair -> pair.key.equals(key)));
 }
Example #5
0
 public Collection<V> values(Function<V, Boolean> condition) {
   return LinqUtils.where(values(), condition);
 }
Example #6
0
 public Collection<V> values() {
   return LinqUtils.select(pairs, pair -> pair.value);
 }
Example #7
0
 public Collection<K> keys() {
   return LinqUtils.select(pairs, pair -> pair.key);
 }