/** * @param e entity * @return true if an entity with the same iri as the input exists in the collection */ public synchronized boolean containsReference(K e) { return map.containsKey(e); }
private boolean containsEntry(K k, V v) { Collection<V> t = map.get(k); if (t == null) { return false; } return t.contains(v); }
/** * {@inheritDoc} */ @Override public boolean putIfAbsent(final KType key, final VType value) { if (!containsKey(key)) { put(key, value); return true; } return false; }
/** * {@inheritDoc} */ @Override public int putAll(final Iterable<? extends ObjectObjectCursor<? extends KType, ? extends VType>> iterable) { final int count = this.size(); for (final ObjectObjectCursor<? extends KType, ? extends VType> c : iterable) { put(c.key, c.value); } return this.size() - count; }
/** * Creates a hash map from two index-aligned arrays of key-value pairs. Default load factor is used. */ public static <KType, VType> ObjectObjectHashMap<KType, VType> from(final KType[] keys, final VType[] values) { if (keys.length != values.length) { throw new IllegalArgumentException("Arrays of keys and values must have an identical length."); } final ObjectObjectHashMap<KType, VType> map = new ObjectObjectHashMap<KType, VType>(keys.length); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; }
private boolean removeInternal(K k, V v) { if (neverTrimmed) { // trimToSize(); } Collection<V> t = map.get(k); if (t == null) { return false; } if (t.size() == 1) { if (t.contains(v)) { map.remove(k); size--; return true; } else { return false; } } boolean removed = t.remove(v); if (removed) { size--; } if (t.isEmpty()) { map.remove(k); } return removed; }
if (other.size() != this.size()) { return false; final EntryIterator it = this.iterator(); if (!other.containsKey(c.key)) { final VType otherValue = other.get(c.key);
/** * @return keyset */ public synchronized Stream<K> keySet() { init(); List<K> l = new ArrayList<>(); Consumer<ObjectCursor<K>> p = c -> l.add(c.value); map.keys().forEach(p); return l.stream(); }
@Override public int removeAll(final ObjectContainer<? super KType> other) { final int before = this.size(); if (!((existing = keys[i]) == null) && other.contains(existing)) { shiftConflictingKeys(i); remove(((KType)(c.value))); return before - this.size();
private Stream<V> values() { List<V> l = new ArrayList<>(); Consumer<ObjectCursor<Collection<V>>> c = q -> l.addAll(q.value); map.values().forEach(c); return l.stream(); }
@Override public synchronized String toString() { return initialized + map.toString(); }
private boolean removeInternal(K k, V v) { if (neverTrimmed) { // trimToSize(); } Collection<V> t = map.get(k); if (t == null) { return false; } if (t.size() == 1) { if (t.contains(v)) { map.remove(k); size--; return true; } else { return false; } } boolean removed = t.remove(v); if (removed) { size--; } if (t.isEmpty()) { map.remove(k); } return removed; }
/** * @return keyset */ public synchronized Stream<K> keySet() { init(); List<K> l = new ArrayList<>(); Consumer<ObjectCursor<K>> p = c -> l.add(c.value); map.keys().forEach(p); return l.stream(); }
private Stream<V> values() { List<V> l = new ArrayList<>(); Consumer<ObjectCursor<Collection<V>>> c = q -> l.addAll(q.value); map.values().forEach(c); return l.stream(); }
@Override public synchronized String toString() { return initialized + map.toString(); }
private int count(K k) { Collection<V> t = map.get(k); if (t == null) { return 0; } return t.size(); }
private boolean removeInternal(K k, V v) { if (neverTrimmed) { // trimToSize(); } Collection<V> t = map.get(k); if (t == null) { return false; } if (t.size() == 1) { if (t.contains(v)) { map.remove(k); size--; return true; } else { return false; } } boolean removed = t.remove(v); if (removed) { size--; } if (t.isEmpty()) { map.remove(k); } return removed; }