import java.util.*; public class LinearScheduler { ArrayList contents; // ArrayList to keep tasks public LinearScheduler() { contents = new ArrayList(); } public void insert(Task t) { contents.add(t); } public boolean contains(Task t) { return contents.contains(t); } public Task next() { if (contents.isEmpty()) return null; int s = 0; // index of the Task with the smallest timestamp for (int i = 0; i < contents.size(); i++){ if (((Task) contents.get(i)).stamp < ((Task) contents.get(s)).stamp) { s = i; } } Task smallest = (Task) contents.get(s); contents.remove(smallest); return smallest; } }