org.eclipse.collections.impl.bimap.mutable.HashBiMap Maven / Gradle / Ivy
/*
* Copyright (c) 2015 Goldman Sachs.
* 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.bimap.mutable;
import java.io.Externalizable;
import java.util.Map;
import org.eclipse.collections.api.bimap.MutableBiMap;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
/**
* A {@link MutableBiMap} which uses two hash tables as its underlying data store.
*
* @since 4.2
*/
public class HashBiMap extends AbstractMutableBiMap implements Externalizable
{
private static final long serialVersionUID = 1L;
public HashBiMap()
{
super(UnifiedMap.newMap(), UnifiedMap.newMap());
}
public HashBiMap(int initialSize)
{
super(UnifiedMap.newMap(initialSize), UnifiedMap.newMap(initialSize));
}
public HashBiMap(Map map)
{
super(map);
}
HashBiMap(Map keysToValues, Map valuesToKeys)
{
super(keysToValues, valuesToKeys);
}
public static HashBiMap newMap()
{
return new HashBiMap();
}
public static HashBiMap newWithKeysValues(K key, V value)
{
return new HashBiMap(1).withKeysValues(key, value);
}
public static HashBiMap newWithKeysValues(K key1, V value1, K key2, V value2)
{
return new HashBiMap(2).withKeysValues(key1, value1, key2, value2);
}
public static HashBiMap newWithKeysValues(K key1, V value1, K key2, V value2, K key3, V value3)
{
return new HashBiMap(3).withKeysValues(key1, value1, key2, value2, key3, value3);
}
public static HashBiMap newWithKeysValues(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)
{
return new HashBiMap(4).withKeysValues(key1, value1, key2, value2, key3, value3, key4, value4);
}
public HashBiMap withKeysValues(K key, V value)
{
this.put(key, value);
return this;
}
public HashBiMap withKeysValues(K key1, V value1, K key2, V value2)
{
this.put(key1, value1);
this.put(key2, value2);
return this;
}
public HashBiMap withKeysValues(K key1, V value1, K key2, V value2, K key3, V value3)
{
this.put(key1, value1);
this.put(key2, value2);
this.put(key3, value3);
return this;
}
public HashBiMap withKeysValues(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)
{
this.put(key1, value1);
this.put(key2, value2);
this.put(key3, value3);
this.put(key4, value4);
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy