View Javadoc

1   /*
2    * 
3    * 
4    */
5   package net.sf.diaz;
6   
7   import java.util.*;
8   
9   
10  /**
11   * 
12   * @author Sean C. Sullivan
13   * 
14   */
15  class IndexedMapImpl<K,V> extends LinkedHashMap<K, V>
16  	implements IndexedMap<K,V>
17  {
18  	private List<V> values = null;
19  	
20  	public IndexedMapImpl()
21  	{
22  		this(100);
23  	}
24  	
25  	public IndexedMapImpl(int initialCapacity)
26  	{
27  		super(initialCapacity);
28  		values = new ArrayList<V>(initialCapacity);
29  	}
30  	
31  	public V put(K key, V value)
32  	{
33  		V result = null;
34  		
35  		result = super.put(key, value);
36  		values.add(value);
37  		
38  		return result;
39  	}
40  
41  	public V remove(Object key)
42  	{
43  		V result = null;
44  		
45  		result = super.remove(key);
46  		values.remove(key);
47  		
48  		return result;
49  	}
50  
51  	public V get(int i)
52  	{
53  		return values.get(i);
54  	}
55  	
56  }