|
Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
public class LinkedHashMap<K,V>
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 arg 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.
| Constructor Summary | |
|---|---|
LinkedHashMap()
Contructs a new empty instance of LinkedHashMap. |
|
LinkedHashMap(int s)
Constructor with specified size. |
|
LinkedHashMap(int s,
float lf)
Constructor with specified size and load factor. |
|
LinkedHashMap(int s,
float lf,
boolean order)
Constructor with specified size, load factor and access order |
|
LinkedHashMap(Map<? extends K,? extends V> map)
Constructor with input map |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all mappings from this HashMap, leaving it empty. |
Object |
clone()
Answers a new HashMap with the same mappings and size as this HashMap. |
Set<Map.Entry<K,V>> |
entrySet()
Answers a Set of the mappings contained in this HashMap. |
V |
get(Object key)
Retrieve the map value corresponding to the given key. |
Set<K> |
keySet()
Answers a Set of the keys contained in this HashMap. |
V |
put(K key,
V value)
Set the mapped value for the given key to the given value. |
void |
putAll(Map<? extends K,? extends V> map)
Put all entries from the given map into the LinkedHashMap |
V |
remove(Object key)
Remove the entry corresponding to the given key. |
protected boolean |
removeEldestEntry(Map.Entry 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. |
Collection<V> |
values()
Answers a Collection of the values contained in this HashMap. |
| Methods inherited from class java.util.HashMap |
|---|
containsKey, containsValue, isEmpty, size |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public LinkedHashMap()
public LinkedHashMap(int s)
s - Size of LinkedHashMap requiredpublic LinkedHashMap(int s,
float lf)
s - Size of LinkedHashMap requiredlf - Load factorpublic LinkedHashMap(int s,
float lf,
boolean order)
s - Size of LinkedHashmap requiredlf - Load factororder - If true indicates that traversal order should begin with most recently accessedpublic LinkedHashMap(Map<? extends K,? extends V> map)
m - Input map| Method Detail |
|---|
public V get(Object key)
get in interface Map<K,V>get in class HashMap<K,V>key - Key value
public V put(K key,
V value)
put in interface Map<K,V>put in class HashMap<K,V>key - Key valuevalue - New mapped value
public void putAll(Map<? extends K,? extends V> map)
putAll in interface Map<K,V>putAll in class HashMap<K,V>map - Input mappublic Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>entrySet in class HashMap<K,V>@SuppressWarnings(value="all") public Set<K> keySet()
keySet in interface Map<K,V>keySet in class HashMap<K,V>@SuppressWarnings(value="all") public Collection<V> values()
values in interface Map<K,V>values in class HashMap<K,V>public V remove(Object key)
remove in interface Map<K,V>remove in class HashMap<K,V>key - the key
protected boolean removeEldestEntry(Map.Entry eldest)
eldest -
public void clear()
clear in interface Map<K,V>clear in class HashMap<K,V>HashMap.isEmpty(),
HashMap.size()public Object clone()
clone in class HashMap<K,V>Cloneable
|
Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||