00001 package cz.vutbr.fit.dudka.SGVis.Data;
00002
00003 import java.util.HashMap;
00004
00010 public class RelationMap<KEY> {
00011 private HashMap<KEY, RelationSet> map;
00012
00013 public RelationMap() {
00014 map = new HashMap<KEY, RelationSet>();
00015 }
00016
00020 public RelationMap(RelationMap<KEY> ref) {
00021 map = new HashMap<KEY, RelationSet>(ref.map);
00022 }
00023
00029 public RelationSet get(Object key) {
00030 RelationSet rset = map.get(key);
00031 if (null==rset)
00032 rset = new RelationSet();
00033 return rset;
00034 }
00035
00041 public void addToSet(KEY key, Relation relation)
00042 {
00043 RelationSet rl = this.get(key);
00044 rl.add(relation);
00045 map.put(key, rl);
00046 }
00047
00051 public RelationMap<KEY> clone() {
00052 return new RelationMap<KEY>(this);
00053 }
00054 }