Package net.sf.jasperreports.engine.util
Class LinkedMap<K,V>
- java.lang.Object
-
- net.sf.jasperreports.engine.util.LinkedMap<K,V>
-
public class LinkedMap<K,V> extends java.lang.ObjectA doubly linked list that can also map entries on keys. The list can be iterated in FIFO order and implements the following operations in constant time:- adding an element at the start
- adding an element at the end
- finding and removing an element based on a key
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classLinkedMap.LinkedValue<K,V>
-
Constructor Summary
Constructors Constructor Description LinkedMap()Creates a list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(K key, V value)Adds a value at the end of the list.voidaddAll(LinkedMap<K,V> map)Adds all entries from the map to this map, preserving the order.voidaddFirst(K key, V value)Adds a value at the start of the listbooleanisEmpty()Determines whether the list is empty.Vpop()Removes and returns the first element in the list.java.util.Map.Entry<K,V>popEntry()Removes and returns the first element in the list.Vremove(K key)Removes and returns an element mapped to a key.protected LinkedMap.LinkedValue<K,V>removeFirst()
-
-
-
Method Detail
-
add
public void add(K key, V value)
Adds a value at the end of the list.- Parameters:
key- the not-null key to which the value is mappedvalue- the value
-
addFirst
public void addFirst(K key, V value)
Adds a value at the start of the list- Parameters:
key- the not-null key to which the value is mappedvalue- the value
-
isEmpty
public boolean isEmpty()
Determines whether the list is empty.- Returns:
- whether the list is empty
-
pop
public V pop()
Removes and returns the first element in the list.- Returns:
- the first element in the list
-
popEntry
public java.util.Map.Entry<K,V> popEntry()
Removes and returns the first element in the list.- Returns:
- the first element in the list
-
removeFirst
protected LinkedMap.LinkedValue<K,V> removeFirst()
-
remove
public V remove(K key)
Removes and returns an element mapped to a key.- Parameters:
key-- Returns:
- the element mapped to the key,
nullif the key is not mapped
-
-