cz/vutbr/fit/dudka/SGVis/Visual/NodeTable.java

Go to the documentation of this file.
00001 package cz.vutbr.fit.dudka.SGVis.Visual;
00002 
00003 import java.util.HashMap;
00004 
00010 class NodeTable {
00011   private HashMap<String,Integer> textToIdMap;
00012   private HashMap<Integer,String> idToTextMap;
00013   public NodeTable() {
00014     textToIdMap = new HashMap<String, Integer>();
00015     idToTextMap = new HashMap<Integer, String>();
00016   }
00017   public void add(String text, int id) {
00018     textToIdMap.put(text, id);
00019     idToTextMap.put(id, text);
00020   }
00021   public void remove(String text) {
00022     Integer id = (Integer) textToIdMap.get(text);
00023     assert (null!=id):"Invalid lookup";
00024     textToIdMap.remove(text);
00025     idToTextMap.remove(id);
00026   }
00027   public void remove(int id) {
00028     String text = (String) idToTextMap.get(id);
00029     assert (null!=text):"Invalid lookup";
00030     idToTextMap.remove(id);
00031     textToIdMap.remove(text);
00032   }
00033   public int getId(String text) {
00034     Integer id = (Integer) textToIdMap.get(text);
00035     assert (null!=id):"Invalid lookup";
00036     return id.intValue();
00037   }
00038   public boolean contains(String text) {
00039     Integer id = (Integer) textToIdMap.get(text);
00040     return (null!=id);
00041   }
00042   public void clear() {
00043     textToIdMap.clear();
00044     idToTextMap.clear();
00045   }
00046 }

Generated on Sat May 3 22:56:09 2008 for SGVis by  doxygen 1.5.4