com.gs.collections.impl.bimap.mutable.HashBiMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gs-collections Show documentation
Show all versions of gs-collections Show documentation
GS Collections is a collections framework for Java. It has JDK-compatible List, Set and Map
implementations with a rich API and set of utility classes that work with any JDK compatible Collections,
Arrays, Maps or Strings. The iteration protocol was inspired by the Smalltalk collection framework.
/*
* Copyright 2013 Goldman Sachs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gs.collections.impl.bimap.mutable;
import java.io.Externalizable;
import java.util.Map;
import com.gs.collections.api.bimap.MutableBiMap;
import com.gs.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