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