2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
8 import java.util.Collection;
9 import java.util.Collections;
10 import java.util.Comparator;
12 import java.util.SortedMap;
13 import java.util.SortedSet;
14 import java.util.TreeMap;
15 import java.util.TreeSet;
23 public class MultiSortedMap<T, V> {
25 private SortedMap<T,SortedSet<V>> mmap;
27 public MultiSortedMap() {
28 mmap = Collections.synchronizedSortedMap( new TreeMap<T,SortedSet<V>>() );
31 public MultiSortedMap(Comparator<? super T> cmprtr) {
32 mmap = Collections.synchronizedSortedMap( new TreeMap<T,SortedSet<V>>(cmprtr) );
40 public void add(T key, V value){
41 SortedSet<V> mapValue = null;
43 if(mmap.containsKey(key)) {
44 mapValue = mmap.get(key);
46 mapValue = Collections.synchronizedSortedSet( new TreeSet<V>() );
50 mmap.put(key, mapValue);
58 public SortedSet<V> get(T key){
62 SortedSet<V> s = new TreeSet<V>();
72 public Set<T> getKeys() {
83 public Collection<SortedSet<V>> getValues() {
104 public boolean contains(T key, V value) {
105 Set<V> t = get( key );
107 return t.contains(value);
117 public boolean containsKey(T key) {
118 return mmap.containsKey(key);
125 public SortedSet<V> remove(T key) {
126 return mmap.remove(key);
135 public boolean removeValue(T key, V value) {
136 Set<V> t = get( key );
138 return t.remove(value);