org.eclipse.collections.impl.map.fixed.AbstractMemoryEfficientMutableMap Maven / Gradle / Ivy
Show all versions of eclipse-collections Show documentation
/*
* Copyright (c) 2022 Goldman Sachs and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package org.eclipse.collections.impl.map.fixed;
import java.util.Map;
import java.util.Set;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.function.Function0;
import org.eclipse.collections.api.block.function.Function2;
import org.eclipse.collections.api.block.predicate.Predicate2;
import org.eclipse.collections.api.block.procedure.Procedure;
import org.eclipse.collections.api.factory.Maps;
import org.eclipse.collections.api.map.FixedSizeMap;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.list.fixed.ArrayAdapter;
import org.eclipse.collections.impl.map.mutable.AbstractMutableMap;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
abstract class AbstractMemoryEfficientMutableMap
extends AbstractMutableMap
implements FixedSizeMap
{
@Override
public V put(K key, V value)
{
throw new UnsupportedOperationException("Cannot call put() on " + this.getClass().getSimpleName());
}
@Override
public V remove(Object key)
{
throw new UnsupportedOperationException("Cannot call remove() on " + this.getClass().getSimpleName());
}
@Override
public void putAll(Map extends K, ? extends V> map)
{
throw new UnsupportedOperationException("Cannot call putAll() on " + this.getClass().getSimpleName());
}
@Override
public void clear()
{
throw new UnsupportedOperationException("Cannot call clear() on " + this.getClass().getSimpleName());
}
@Override
public V removeKey(K key)
{
throw new UnsupportedOperationException("Cannot call removeKey() on " + this.getClass().getSimpleName());
}
@Override
public boolean removeAllKeys(Set extends K> keys)
{
throw new UnsupportedOperationException("Cannot call removeAllKeys() on " + this.getClass().getSimpleName());
}
@Override
public boolean removeIf(Predicate2 super K, ? super V> predicate)
{
throw new UnsupportedOperationException("Cannot call removeIf() on " + this.getClass().getSimpleName());
}
@Override
public MutableMap collectKeysAndValues(
Iterable iterable,
Function super E, ? extends K> keyFunction,
Function super E, ? extends V> valueFunction)
{
throw new UnsupportedOperationException("Cannot call collectKeysAndValues() on " + this.getClass().getSimpleName());
}
@Override
public V updateValue(K key, Function0 extends V> factory, Function super V, ? extends V> function)
{
throw new UnsupportedOperationException(this.getClass().getSimpleName() + ".updateValue() not implemented yet");
}
@Override
public V updateValueWith(K key, Function0 extends V> factory, Function2 super V, ? super P, ? extends V> function, P parameter)
{
throw new UnsupportedOperationException(this.getClass().getSimpleName() + ".updateValueWith() not implemented yet");
}
@Override
public MutableMap newEmpty()
{
return Maps.mutable.empty();
}
@Override
public MutableMap newEmpty(int capacity)
{
return UnifiedMap.newMap(capacity);
}
@Override
public MutableMap withAllKeyValues(Iterable extends Pair extends K, ? extends V>> keyValues)
{
MutableMap map = this;
for (Pair extends K, ? extends V> keyVal : keyValues)
{
map = map.withKeyValue(keyVal.getOne(), keyVal.getTwo());
}
return map;
}
@Override
public MutableMap withAllKeyValueArguments(Pair extends K, ? extends V>... keyValues)
{
return this.withAllKeyValues(ArrayAdapter.adapt(keyValues));
}
@Override
public MutableMap withoutAllKeys(Iterable extends K> keys)
{
MutableMap map = this;
for (K key : keys)
{
map = map.withoutKey(key);
}
return map;
}
@Override
public FixedSizeMap tap(Procedure super V> procedure)
{
this.forEach(procedure);
return this;
}
@Override
public abstract FixedSizeMap select(Predicate2 super K, ? super V> predicate);
@Override
public abstract FixedSizeMap collectValues(Function2 super K, ? super V, ? extends R> function);
@Override
public abstract FixedSizeMap collect(Function2 super K, ? super V, Pair> function);
@Override
public abstract FixedSizeMap reject(Predicate2 super K, ? super V> predicate);
}