package com.etixpert.evolution.gui.servlets;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.TreeMap;

public class SortingMap {

	TreeMap treeMap;
	
	public SortingMap() {
		treeMap = new TreeMap();
	}

	public void put (Object key, Object value) {
		if (treeMap.containsKey(key)) {
			List vals = (List)treeMap.get(key);
			vals.add(value);
		} else {
			List list = new LinkedList();
			list.add(value);
			treeMap.put(key, list);
		}
	}
	
	public List getSortedValues() {
		List ret = new LinkedList();
		for (Iterator it = treeMap.keySet().iterator(); it.hasNext(); ) {
			Object key = it.next();
			List vals = (List)treeMap.get(key);
			for (int i = 0; i<vals.size(); i++)
				ret.add(vals.get(i));
		}
		return ret;
	}
}
