summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoDeque.java
diff options
context:
space:
mode:
Diffstat (limited to 'org/madore/damlengine/TodoDeque.java')
-rw-r--r--org/madore/damlengine/TodoDeque.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoDeque.java b/org/madore/damlengine/TodoDeque.java
new file mode 100644
index 0000000..e030e29
--- /dev/null
+++ b/org/madore/damlengine/TodoDeque.java
@@ -0,0 +1,53 @@
+package org.madore.damlengine;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+public final class TodoDeque {
+
+ // FIXME: having everything static is ugly as hell... maybe this
+ // should be instantiatable?
+
+ private TodoDeque() { } // Forbid instantiation
+
+ private static LinkedList<TodoItem> todoDeque = new LinkedList<TodoItem>();
+
+ {
+ todoDeque = new LinkedList<TodoItem>();
+ }
+
+ public static void registerAtEnd(TodoItem it) {
+ todoDeque.addLast(it);
+ }
+
+ public static void registerAtEnd(Collection<TodoItem> them) {
+ todoDeque.addAll(them);
+ }
+
+ public static void registerAtStart(TodoItem it) {
+ todoDeque.addFirst(it);
+ }
+
+ public static void registerAtStart(Collection<TodoItem> them) {
+ todoDeque.addAll(0, them);
+ }
+
+ public static TodoItem removeNext() {
+ return todoDeque.poll();
+ }
+
+ public static boolean dispatchOne() {
+ TodoItem it = removeNext();
+ if ( it != null ) {
+ it.dispatch();
+ return true;
+ } else
+ return false;
+ }
+
+ public static void dispatchLoop() {
+ while ( dispatchOne() )
+ ;
+ }
+
+}