@Override public synchronized boolean replace(K key, V oldValue, V newValue) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); if (index >= 0 && current.entries[index].getValue().equals(oldValue)) { COWEntry<K, V> newEntry = new COWEntry<>(key, newValue); this.holder = current.replace(index, newEntry); return true; } return false; }
@Override public synchronized boolean replace(K key, V oldValue, V newValue) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); if (index >= 0 && current.entries[index].getValue().equals(oldValue)) { COWEntry<K, V> newEntry = new COWEntry<>(key, newValue); this.holder = current.replace(index, newEntry); return true; } return false; }
@Override public synchronized boolean replace(K key, V oldValue, V newValue) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); if (index >= 0 && current.entries[index].getValue().equals(oldValue)) { COWEntry<K, V> newEntry = new COWEntry<>(key, newValue); this.holder = current.replace(index, newEntry); return true; } return false; }
@Override public synchronized V put(K key, V value) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); COWEntry<K, V> newEntry = new COWEntry<>(key, value); if (index >= 0) { this.holder = current.replace(index, newEntry); return current.entries[index].getValue(); } else { this.holder = current.insert(-(index + 1), newEntry); } return null; }
@Override public synchronized V put(K key, V value) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); COWEntry<K, V> newEntry = new COWEntry<>(key, value); if (index >= 0) { this.holder = current.replace(index, newEntry); return current.entries[index].getValue(); } else { this.holder = current.insert(-(index + 1), newEntry); } return null; }
@Override public synchronized V replace(K key, V value) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); if (index >= 0) { COWEntry<K, V> newEntry = new COWEntry<>(key, value); this.holder = current.replace(index, newEntry); return current.entries[index].getValue(); } return null; }
@Override public synchronized boolean replace(K key, V oldValue, V newValue) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); if (index >= 0 && current.entries[index].getValue().equals(oldValue)) { COWEntry<K, V> newEntry = new COWEntry<>(key, newValue); this.holder = current.replace(index, newEntry); return true; } return false; }
@Override public synchronized V replace(K key, V value) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); if (index >= 0) { COWEntry<K, V> newEntry = new COWEntry<>(key, value); this.holder = current.replace(index, newEntry); return current.entries[index].getValue(); } return null; }
@Override public synchronized V replace(K key, V value) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); if (index >= 0) { COWEntry<K, V> newEntry = new COWEntry<>(key, value); this.holder = current.replace(index, newEntry); return current.entries[index].getValue(); } return null; }
@Override public synchronized V put(K key, V value) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); COWEntry<K, V> newEntry = new COWEntry<>(key, value); if (index >= 0) { this.holder = current.replace(index, newEntry); return current.entries[index].getValue(); } else { this.holder = current.insert(-(index + 1), newEntry); } return null; }
@Override public synchronized V replace(K key, V value) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); if (index >= 0) { COWEntry<K, V> newEntry = new COWEntry<>(key, value); this.holder = current.replace(index, newEntry); return current.entries[index].getValue(); } return null; }
@Override public synchronized V put(K key, V value) { ArrayHolder<K, V> current = this.holder; int index = current.find(key); COWEntry<K, V> newEntry = new COWEntry<>(key, value); if (index >= 0) { this.holder = current.replace(index, newEntry); return current.entries[index].getValue(); } else { this.holder = current.insert(-(index + 1), newEntry); } return null; }