1 package prefuse.util.collections; 2 3 import java.util.HashMap ; 4 import java.util.LinkedList ; 5 6 11 public class Queue { 12 13 15 private LinkedList m_list = new LinkedList (); 16 private HashMap m_map = new HashMap (); 17 18 public void clear() { 19 m_list.clear(); 20 m_map.clear(); 21 } 22 23 public boolean isEmpty() { 24 return m_list.isEmpty(); 25 } 26 27 public void add(Object o, int depth) { 28 m_list.add(o); 29 visit(o, depth); 30 } 31 32 public int getDepth(Object o) { 33 Integer d = (Integer )m_map.get(o); 34 return ( d==null ? -1 : d.intValue() ); 35 } 36 37 public void visit(Object o, int depth) { 38 m_map.put(o, new Integer (depth)); 39 } 40 41 public Object removeFirst() { 42 return m_list.removeFirst(); 43 } 44 45 public Object removeLast() { 46 return m_list.removeLast(); 47 } 48 49 } | Popular Tags |