public class IntIntHashMultiMap extends Object implements IntIntMultiMap
MultiMap
implementation for mapping int
primitives as both
keys and values using a hashing strategy. This class offers a noticeable
performance improvement over the equivalent HashMultiMap<Integer,Integer>
by operating and representing the keys
and values only in their primitive state.Constructor and Description |
---|
IntIntHashMultiMap() |
IntIntHashMultiMap(Map<Integer,Integer> m)
Constructs this map and adds in all the mapping from the provided
Map |
Modifier and Type | Method and Description |
---|---|
Map<Integer,Set<Integer>> |
asMap()
Returns a
Map -based view of this MultiMap |
void |
clear()
Removes all of the mappings from this multi-map.
|
boolean |
containsKey(int key)
Returns
true if this multi-map contains a mapping for the
specified key. |
boolean |
containsKey(Object key)
Returns
true if this multi-map contains a mapping for the
specified key. |
boolean |
containsMapping(int key,
int value)
Returns
true if this multi-map contains a mapping from specified
key to the specified value. |
boolean |
containsMapping(Object key,
Object value)
Returns
true if this multi-map contains a mapping from specified
key to the specified value. |
boolean |
containsValue(int value)
Returns
true if this multi-map contains from any key to the
specified value. |
boolean |
containsValue(Object value)
Returns
true if this multi-map contains from any key to the
specified value. |
Set<Map.Entry<Integer,Integer>> |
entrySet()
Returns a
Set view of all the key-value mappings contained in
this multi-map. |
IntSet |
get(int key)
Returns the set of values mapped to this key or
null of the key
is not mapped to any values |
IntSet |
get(Object key)
Returns the set of values mapped to this key or
null of the key
is not mapped to any values |
boolean |
isEmpty()
Returns
true if this multi-map contains no mappings. |
IntSet |
keySet()
Returns a
Set view of the mappings contained in this multi-map. |
boolean |
put(Integer key,
Integer value)
Adds the specified value to the set of values associated with the
specified key in this map.
|
boolean |
put(int key,
int value)
Adds the specified value to the set of values associated with the
specified key in this map.
|
void |
putAll(IntIntMultiMap m)
Copies all of the mappings from the specified map to this mutli-map
|
void |
putAll(Map<? extends Integer,? extends Integer> m)
Copies all of the mappings from the specified map to this mutli-map
|
void |
putAll(MultiMap<? extends Integer,? extends Integer> m)
Copies all of the mappings from the specified mulit-map to this mutli-map
|
boolean |
putMany(int key,
Collection<Integer> values)
Adds all of the specified values to the set of values associated with the
specified key in this map.
|
boolean |
putMany(Integer key,
Collection<Integer> values)
Adds all of the specified values to the set of values associated with the
specified key in this map.
|
boolean |
putMany(Integer key,
IntCollection values) |
boolean |
putMany(int key,
IntCollection values)
Adds all of the specified values to the set of values associated with the
specified key in this map.
|
int |
range()
Returns the number of values maped to keys.
|
IntSet |
remove(int key)
Removes the mapping for a key from this multi-map if it is present
|
IntSet |
remove(Integer key)
Removes the mapping for a key from this multi-map if it is present,
returning any mapped values to that key
|
boolean |
remove(int key,
int value)
Removes the specified mapping for a key if it is present.
|
boolean |
remove(Object key,
Object value)
Removes the specified mapping for a key if it is present.
|
int |
size()
Returns the number of keys that are mapped to one or more values in this
multi-map.
|
String |
toString()
Returns the string form of this multi-map
|
IntCollection |
values()
Returns a
Collection view of the values contained in this map. |
Collection<Set<Integer>> |
valueSets()
Returns a
Collection view of the sets of values mapped to each
key in this map. |
public Map<Integer,Set<Integer>> asMap()
MultiMap
Map
-based view of this MultiMap
public void clear()
public boolean containsKey(int key)
true
if this multi-map contains a mapping for the
specified key.containsKey
in interface IntIntMultiMap
public boolean containsKey(Object key)
true
if this multi-map contains a mapping for the
specified key.containsKey
in interface MultiMap<Integer,Integer>
public boolean containsMapping(int key, int value)
true
if this multi-map contains a mapping from specified
key to the specified value.containsMapping
in interface IntIntMultiMap
public boolean containsMapping(Object key, Object value)
true
if this multi-map contains a mapping from specified
key to the specified value.containsMapping
in interface MultiMap<Integer,Integer>
public boolean containsValue(int value)
true
if this multi-map contains from any key to the
specified value.containsValue
in interface IntIntMultiMap
public boolean containsValue(Object value)
true
if this multi-map contains from any key to the
specified value.containsValue
in interface MultiMap<Integer,Integer>
public Set<Map.Entry<Integer,Integer>> entrySet()
Set
view of all the key-value mappings contained in
this multi-map.public IntSet get(int key)
null
of the key
is not mapped to any valuesget
in interface IntIntMultiMap
public IntSet get(Object key)
null
of the key
is not mapped to any valuespublic boolean isEmpty()
true
if this multi-map contains no mappings.public boolean put(int key, int value)
put
in interface IntIntMultiMap
key
- key with which the specified value is to be associatedvalue
- a value to be associated with the specified keytrue
if the provided value was not already in the set of
value mapped to the specified keypublic boolean put(Integer key, Integer value)
public void putAll(Map<? extends Integer,? extends Integer> m)
public void putAll(MultiMap<? extends Integer,? extends Integer> m)
public void putAll(IntIntMultiMap m)
putAll
in interface IntIntMultiMap
public boolean putMany(int key, Collection<Integer> values)
putMany
in interface IntIntMultiMap
key
- key with which the specified value is to be associatedvalues
- a collection of values to be associated with the specified
keytrue
if at least one of the provided value was not
already in the set of value mapped to the specified keypublic boolean putMany(Integer key, Collection<Integer> values)
putMany
in interface MultiMap<Integer,Integer>
key
- key with which the specified value is to be associatedvalues
- a collection of values to be associated with the specified
keytrue
if at least one of the provided value was not
already in the set of value mapped to the specified keypublic boolean putMany(int key, IntCollection values)
putMany
in interface IntIntMultiMap
key
- key with which the specified value is to be associatedvalues
- a collection of values to be associated with the specified
keytrue
if at least one of the provided value was not
already in the set of value mapped to the specified keypublic boolean putMany(Integer key, IntCollection values)
public int range()
MultiMap.size()
. However, in the case where a key is mapped to more
than one value, this method will always return a value strictly
larger than size()
.public IntSet remove(int key)
remove
in interface IntIntMultiMap
public IntSet remove(Integer key)
public boolean remove(int key, int value)
remove
in interface IntIntMultiMap
true
if the specified mapping was removedpublic boolean remove(Object key, Object value)
public int size()
size
in interface MultiMap<Integer,Integer>
MultiMap.range()
public String toString()
public IntCollection values()
Collection
view of the values contained in this map. The collection and its Iterator
are backed by the
map, so changes to the map are reflected in the collection, and
vice-versa.public Collection<Set<Integer>> valueSets()
Collection
view of the sets of values mapped to each
key in this map.Copyright © 2012. All Rights Reserved.