1 package jodd.util; 2 3 import java.util.LinkedList; 4 import java.util.NoSuchElementException; 5 6 9 public class SimpleQueue { 10 11 private LinkedList list = new LinkedList(); 12 13 18 public void put(Object o) { 19 list.addLast(o); 20 } 21 22 27 public Object get() { 28 Object result = null; 29 try { 30 result = list.removeFirst(); 31 } catch (NoSuchElementException nsee) { 32 } 33 return result; 34 } 35 36 41 public Object[] getAll() { 42 Object[] res = list.toArray(); 43 list.clear(); 44 return res; 45 } 46 47 48 53 public Object peek() { 54 return list.getFirst(); 55 } 56 57 62 public boolean isEmpty() { 63 return list.isEmpty(); 64 } 65 } 66 | Popular Tags |