Code example for TreeMap

Methods: containsKey, put

0
		TreeMap<Integer, CmpCommand> map_entry = null; 
		if (cmp_map.containsKey(cmp.getRegSource())) 
			map_entry = cmp_map.get(cmp.getRegSource()); 
		else 
		{ 
			map_entry = new TreeMap<Integer, CmpCommand>(); 
			cmp_map.put(cmp.getRegSource(), map_entry); 
		} 
		if (!map_entry.containsKey(cmp.getLocation())) 
			map_entry.put(cmp.getLocation(), cmp); 
	} 
	 
	public Collection<CmpCommand> get(Integer reg_source) 
	{ 
		TreeMap<Integer, CmpCommand> map_entry = cmp_map.get(reg_source); 
		return (map_entry != null ? map_entry.values(): null); 
	} 
 
}