public class IdentityMap<K,V> extends Object implements Iterable<IdentityMap.Entry<K,V>>
Modifier and Type | Class and Description |
---|---|
static class |
IdentityMap.Entries<K,V> |
static class |
IdentityMap.Entry<K,V> |
static class |
IdentityMap.Keys<K> |
static class |
IdentityMap.Values<V> |
Modifier and Type | Field and Description |
---|---|
int |
size |
Constructor and Description |
---|
IdentityMap()
Creates a new map with an initial capacity of 32 and a load factor of 0.8.
|
IdentityMap(IdentityMap map)
Creates a new map identical to the specified map.
|
IdentityMap(int initialCapacity)
Creates a new map with a load factor of 0.8.
|
IdentityMap(int initialCapacity,
float loadFactor)
Creates a new map with the specified initial capacity and load factor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
clear(int maximumCapacity)
Clears the map and reduces the size of the backing arrays to be the specified capacity if they are larger.
|
boolean |
containsKey(K key) |
boolean |
containsValue(Object value,
boolean identity)
Returns true if the specified value is in the map.
|
void |
ensureCapacity(int additionalCapacity)
Increases the size of the backing array to accommodate the specified number of additional items.
|
IdentityMap.Entries<K,V> |
entries()
Returns an iterator for the entries in the map.
|
boolean |
equals(Object obj) |
K |
findKey(Object value,
boolean identity)
Returns the key for the specified value, or null if it is not in the map.
|
V |
get(K key) |
V |
get(K key,
V defaultValue) |
int |
hashCode() |
Iterator<IdentityMap.Entry<K,V>> |
iterator() |
IdentityMap.Keys<K> |
keys()
Returns an iterator for the keys in the map.
|
V |
put(K key,
V value) |
V |
remove(K key) |
void |
shrink(int maximumCapacity)
Reduces the size of the backing arrays to be the specified capacity or less.
|
String |
toString() |
IdentityMap.Values<V> |
values()
Returns an iterator for the values in the map.
|
forEach, spliterator
public IdentityMap()
public IdentityMap(int initialCapacity)
public IdentityMap(int initialCapacity, float loadFactor)
public IdentityMap(IdentityMap map)
public void shrink(int maximumCapacity)
public void clear(int maximumCapacity)
public void clear()
public boolean containsValue(Object value, boolean identity)
identity
- If true, uses == to compare the specified value with values in the map. If false, uses
equals(Object)
.public boolean containsKey(K key)
public K findKey(Object value, boolean identity)
identity
- If true, uses == to compare the specified value with values in the map. If false, uses
equals(Object)
.public void ensureCapacity(int additionalCapacity)
public Iterator<IdentityMap.Entry<K,V>> iterator()
iterator
in interface Iterable<IdentityMap.Entry<K,V>>
public IdentityMap.Entries<K,V> entries()
IdentityMap.Entries
constructor for nested or multithreaded iteration.public IdentityMap.Values<V> values()
IdentityMap.Entries
constructor for nested or multithreaded iteration.public IdentityMap.Keys<K> keys()
IdentityMap.Entries
constructor for nested or multithreaded iteration.Copyright © 2015. All rights reserved.