package eu.ydp.empiria.player.client.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;


public class StackMap<K, V> extends TreeMap<K, V> {
	
	private static final long serialVersionUID = -5203287630904024114L;

	protected List<K> keys;
	protected List<V> values;

	public StackMap(){
		super();
		keys = new ArrayList<K>();
		values = new ArrayList<V>();
	}

	@Override
	public V put(K key, V value){
		keys.add(key);
		values.add(value);
		return super.put(key, value);
	}

	@Override
	public void putAll(Map<? extends K, ? extends V> m){
		keys.addAll(m.keySet());
		values.addAll(m.values());
		super.putAll(m);
	}
	
	@Override
	public void clear(){
		keys.clear();
		values.clear();
		super.clear();
	}
	
	public List<K> getKeys(){
		return keys;
	}
	
	public List<V> getValues(){
		return values;
	}
	
}

@@ -205,29 +205,8 @@
  V%3E 
-extends TreeMap%3CK, V%3E
  %7B%0D%0A
@@ -433,34 +433,24 @@
 %3E();%0D%0A%09%7D%0D%0A%0D%0A
-%09@Override
 %0D%0A%09public V 
@@ -523,201 +523,22 @@
 turn
- super.put(key,
  value
-)
 ;%0D%0A%09%7D%0D%0A
-%0D%0A
 %09
-@Override%0D%0A%09public void putAll(Map%3C? extends K, ? extends V%3E m)%7B%0D%0A%09%09keys.addAll(m.keySet());%0D%0A%09%09values.addAll(m.values());%0D%0A%09%09super.putAll(m);%0D%0A%09%7D%0D%0A%09%0D%0A%09@Override
 %0D%0A%09p
@@ -598,26 +598,8 @@
 );%0D%0A
-%09%09super.clear();%0D%0A
 %09%7D%0D%0A
@@ -707,11 +707,178 @@
 %0A%09%7D%0D%0A%09%0D%0A
+%09public boolean containsKey(K key)%7B%0D%0A%09%09return keys.contains(key);%0D%0A%09%7D%0D%0A%09%0D%0A%09public V get(K key)%7B%0D%0A%09%09int index = keys.indexOf(key);%0D%0A%09%09return values.get(index);%0D%0A%09%7D%0D%0A%09%0D%0A
 %7D%0D%0A

make StackMap based on Lists only