ptolemy.actor.gt.data
Class SequentialTwoWayHashMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by ptolemy.actor.gt.data.TwoWayHashMap<K,V>
              extended by ptolemy.actor.gt.data.SequentialTwoWayHashMap<K,V>
Type Parameters:
K - The key type.
V - The value type.
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>
Direct Known Subclasses:
MatchResult

public class SequentialTwoWayHashMap<K,V>
extends TwoWayHashMap<K,V>

A two-way hash map where the keys are sorted. The keys are sorted in the order in which they are added to this two-way hash map.

Since:
Ptolemy II 8.0
Version:
$Id: SequentialTwoWayHashMap.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Thomas Huining Feng
See Also:
Serialized Form
Accepted Rating:
Red (tfeng)
Proposed Rating:
Yellow (tfeng)

Field Summary
private  java.util.List<K> _keySequence
          The sequence of the keys, sorted in the order in which they are added to this two-way hash map.
 
Constructor Summary
SequentialTwoWayHashMap()
           
 
Method Summary
 void clear()
          Clear this two-way hash map.
 java.lang.Object clone()
          Clone this two-way hash map and return the clone.
 java.util.List<K> keys()
          Return a sorted list of keys.
 V put(K key, V value)
          Put a value into this two-way hash map and associate it with a key.
 V remove(java.lang.Object key)
          Remove the value associated with the given key.
 void removeLast()
          Remove the value associated with the last key.
 void retain(int count)
          Retain only the first count keys and their values, and remove the other keys and values.
 
Methods inherited from class ptolemy.actor.gt.data.TwoWayHashMap
containsValue, getKey, values
 
Methods inherited from class java.util.HashMap
containsKey, entrySet, get, isEmpty, keySet, putAll, 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
 

Field Detail

_keySequence

private java.util.List<K> _keySequence
The sequence of the keys, sorted in the order in which they are added to this two-way hash map.

Constructor Detail

SequentialTwoWayHashMap

public SequentialTwoWayHashMap()
Method Detail

clear

public void clear()
Clear this two-way hash map.

Specified by:
clear in interface java.util.Map<K,V>
Overrides:
clear in class TwoWayHashMap<K,V>

clone

public java.lang.Object clone()
Clone this two-way hash map and return the clone.

Overrides:
clone in class TwoWayHashMap<K,V>
Returns:
The clone.

keys

public java.util.List<K> keys()
Return a sorted list of keys.

Returns:
The list of keys.

put

public V put(K key,
             V value)
Put a value into this two-way hash map and associate it with a key.

Specified by:
put in interface java.util.Map<K,V>
Overrides:
put in class TwoWayHashMap<K,V>
Parameters:
key - The key.
value - The value.
Returns:
The value previously associated with the key in this two-way hash map.

remove

public V remove(java.lang.Object key)
Remove the value associated with the given key.

Specified by:
remove in interface java.util.Map<K,V>
Overrides:
remove in class TwoWayHashMap<K,V>
Parameters:
key - The key.
Returns:
The removed value, or null if not found.

removeLast

public void removeLast()
Remove the value associated with the last key.


retain

public void retain(int count)
Retain only the first count keys and their values, and remove the other keys and values.

Parameters:
count - The number of key-value pairs to be retained.