| java.util.LinkedHashMap
LinkedHashMap | public class LinkedHashMap extends HashMap (Code) | | LinkedHashMap is a variant on HashMap. Its entries are kept in a
doubly-linked list. The iteration order is, by default, the order in which
keys were inserted.
If the three argument constructor is used, and order is
specified as true , the iteration would be in the order that
entries were accessed. The access order gets affected by put(), get(),
putAll() operations, but not by operations on the collection views.
Null elements are allowed, and all the optional Map operations are supported.
since: 1.4 |
Inner Class :final static class LinkedHashMapEntrySet extends HashMapEntrySet | |
Inner Class :final static class LinkedHashMapEntry extends Entry | |
Constructor Summary | |
public | LinkedHashMap() Constructs a new empty instance of LinkedHashMap. | public | LinkedHashMap(int s) Constructor with specified size. | public | LinkedHashMap(int s, float lf) Constructor with specified size and load factor. | public | LinkedHashMap(int s, float lf, boolean order) | public | LinkedHashMap(Map<? extends K, ? extends V> m) |
Method Summary | |
public void | clear() Removes all mappings from this HashMap, leaving it empty. | public boolean | containsValue(Object value) Searches this map for the specified value. | Entry<K, V> | createEntry(K key, int index, V value) | Entry<K, V> | createHashedEntry(K key, int index, int hash) | public Set<Map.Entry<K, V>> | entrySet() Answers a Set of the mappings contained in this HashMap. | public V | get(Object key) Retrieve the map value corresponding to the given key. | public Set<K> | keySet() Answers a Set of the keys contained in this HashMap. | void | linkEntry(LinkedHashMapEntry<K, V> m) | Entry<K, V>[] | newElementArray(int s) | public V | put(K key, V value) Set the mapped value for the given key to the given value. | V | putImpl(K key, V value) | public V | remove(Object key) Remove the entry corresponding to the given key. | protected boolean | removeEldestEntry(Map.Entry<K, V> eldest) This method is queried from the put and putAll methods to check if the
eldest member of the map should be deleted before adding the new member. | public Collection<V> | values() Answers a Collection of the values contained in this HashMap. |
LinkedHashMap | public LinkedHashMap()(Code) | | Constructs a new empty instance of LinkedHashMap.
|
LinkedHashMap | public LinkedHashMap(int s)(Code) | | Constructor with specified size.
Parameters: s - Size of LinkedHashMap required |
LinkedHashMap | public LinkedHashMap(int s, float lf)(Code) | | Constructor with specified size and load factor.
Parameters: s - Size of LinkedHashMap required Parameters: lf - Load factor |
LinkedHashMap | public LinkedHashMap(int s, float lf, boolean order)(Code) | | Constructor with specified size, load factor and access order
Parameters: s - Size of LinkedHashmap required Parameters: lf - Load factor Parameters: order - If true indicates that traversal order should begin with mostrecently accessed |
LinkedHashMap | public LinkedHashMap(Map<? extends K, ? extends V> m)(Code) | | Constructor with input map
Parameters: m - Input map |
containsValue | public boolean containsValue(Object value)(Code) | | Searches this map for the specified value.
Parameters: value - the object to search for true if value is a value of this HashMap, falseotherwise |
createEntry | Entry<K, V> createEntry(K key, int index, V value)(Code) | | |
createHashedEntry | Entry<K, V> createHashedEntry(K key, int index, int hash)(Code) | | |
entrySet | public Set<Map.Entry<K, V>> entrySet()(Code) | | Answers a Set of the mappings contained in this HashMap. Each element in
the set is a Map.Entry. The set is backed by this HashMap so changes to
one are reflected by the other. The set does not support adding.
a Set of the mappings |
get | public V get(Object key)(Code) | | Retrieve the map value corresponding to the given key.
Parameters: key - Key value mapped value or null if the key is not in the map |
keySet | public Set<K> keySet()(Code) | | Answers a Set of the keys contained in this HashMap. The set is backed by
this HashMap so changes to one are reflected by the other. The set does
not support adding.
a Set of the keys |
linkEntry | void linkEntry(LinkedHashMapEntry<K, V> m)(Code) | | |
newElementArray | Entry<K, V>[] newElementArray(int s)(Code) | | Create a new element array
Parameters: s - Reference to the element array |
put | public V put(K key, V value)(Code) | | Set the mapped value for the given key to the given value.
Parameters: key - Key value Parameters: value - New mapped value The old value if the key was already in the map or nullotherwise. |
putImpl | V putImpl(K key, V value)(Code) | | |
remove | public V remove(Object key)(Code) | | Remove the entry corresponding to the given key.
Parameters: key - the key the value associated with the key or null if the key was no inthe map |
removeEldestEntry | protected boolean removeEldestEntry(Map.Entry<K, V> eldest)(Code) | | This method is queried from the put and putAll methods to check if the
eldest member of the map should be deleted before adding the new member.
If this map was created with accessOrder = true, then the result of
removeEldesrEntry is assumed to be false.
Parameters: eldest - true if the eldest member should be removed |
values | public Collection<V> values()(Code) | | Answers a Collection of the values contained in this HashMap. The
collection is backed by this HashMap so changes to one are reflected by
the other. The collection does not support adding.
a Collection of the values |
|
|