Code example for TreeMap

Methods: containsValuecontainsKeyput

public class SimpleItemManager implements Manager<Item> { 
	private final TreeMap<String, Item> itemList = new TreeMap<String, Item>(); 
	public boolean register(Item item) throws JPokemonError { 
		if (itemList.containsKey(item.getName())) { 
			throw new JPokemonError("A item with the name " + item.getName() + " has already been registered!"); 
		if (itemList.containsValue(item)) { 
			throw new JPokemonError("This item is already registered!"); 
		itemList.put(item.getName(), item); 
		return true; 
	public boolean isRegistered(Item item) { 
		return itemList.containsValue(item);