1 3 package jodd.util.collection; 4 5 import java.util.LinkedList ; 6 7 10 public class SimpleQueue { 11 12 private LinkedList list = new LinkedList (); 13 14 17 public void put(Object o) { 18 list.addLast(o); 19 } 20 21 26 public Object get() { 27 if (list.isEmpty()) { 28 return null; 29 } 30 return list.removeFirst(); 31 } 32 33 36 public Object [] getAll() { 37 Object [] res = new Object [list.size()]; 38 for (int i = 0; i < res.length; i++) { 39 res[i] = list.get(i); 40 } 41 list.clear(); 42 return res; 43 } 44 45 46 49 public Object peek() { 50 return list.getFirst(); 51 } 52 53 56 public boolean isEmpty() { 57 return list.isEmpty(); 58 } 59 60 63 public int size() { 64 return list.size(); 65 } 66 } 67 | Popular Tags |