1 package net.matuschek.spider; 2 3 6 7 8 import java.util.Vector ; 9 10 20 public class MemoryTaskList 21 implements TaskList 22 { 23 24 25 31 private Vector list = new Vector (); 32 33 34 37 public MemoryTaskList() { 38 } 39 40 41 45 public synchronized void add(RobotTask task) { 46 list.add(task); 47 } 48 49 50 54 public synchronized void addAtStart(RobotTask task) { 55 list.add(0,task); 56 } 57 58 59 62 public synchronized void clear() { 63 list.clear(); 64 } 65 66 67 70 public synchronized boolean contains(RobotTask task) { 71 return list.contains(task); 72 } 73 74 75 78 public synchronized boolean remove(RobotTask task) { 79 return list.remove(task); 80 } 81 82 83 89 public synchronized RobotTask removeFirst() 90 throws ArrayIndexOutOfBoundsException 91 { 92 RobotTask task = (RobotTask)list.elementAt(0); 93 list.removeElementAt(0); 94 return task; 95 } 96 97 98 101 public synchronized int size() { 102 return list.size(); 103 } 104 105 106 113 public synchronized RobotTask elementAt(int position) 114 throws ArrayIndexOutOfBoundsException 115 { 116 return (RobotTask)(list.elementAt(position)); 117 } 118 119 } 120 | Popular Tags |