summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoDeque.java
diff options
context:
space:
mode:
authorDavid A. Madore <david@procyon.(none)>2010-04-15 21:07:01 +0200
committerDavid A. Madore <david@procyon.(none)>2010-04-15 21:07:01 +0200
commit9176d80ae6dcad88da79714d934b226afe66c1ad (patch)
tree32c843f6e7e63d5e997525296b0921cc50f53ddb /org/madore/damlengine/TodoDeque.java
parent5c6ccfca16a421860cd57d11e41d94d8a70cda76 (diff)
downloaddamlengine-9176d80ae6dcad88da79714d934b226afe66c1ad.tar.gz
damlengine-9176d80ae6dcad88da79714d934b226afe66c1ad.tar.bz2
damlengine-9176d80ae6dcad88da79714d934b226afe66c1ad.zip
Instantiate TodoDeque rather than using static variables.
Unfortunately, processing is now rather significantly slower.
Diffstat (limited to 'org/madore/damlengine/TodoDeque.java')
-rw-r--r--org/madore/damlengine/TodoDeque.java42
1 files changed, 22 insertions, 20 deletions
diff --git a/org/madore/damlengine/TodoDeque.java b/org/madore/damlengine/TodoDeque.java
index 037723b..eb90006 100644
--- a/org/madore/damlengine/TodoDeque.java
+++ b/org/madore/damlengine/TodoDeque.java
@@ -5,47 +5,49 @@ import java.util.LinkedList;
public final class TodoDeque {
- // FIXME: having everything static is ugly as hell... maybe this
- // should be instantiatable?
+ private LinkedList<TodoItem> deque;
- private TodoDeque() { } // Forbid instantiation
-
- private static LinkedList<TodoItem> todoDeque = new LinkedList<TodoItem>();
-
- {
- todoDeque = new LinkedList<TodoItem>();
+ public TodoDeque() {
+ deque = new LinkedList<TodoItem>();
}
- public static void registerAtEnd(TodoItem it) {
- todoDeque.addLast(it);
+ public void registerAtEnd(TodoItem it) {
+ it.ownerDeque = this;
+ deque.addLast(it);
}
- public static void registerAtEnd(Collection<? extends TodoItem> them) {
- todoDeque.addAll(them);
+ public void registerAtEnd(Collection<? extends TodoItem> them) {
+ for ( TodoItem it : them )
+ it.ownerDeque = this;
+ deque.addAll(them);
}
- public static void registerAtStart(TodoItem it) {
- todoDeque.addFirst(it);
+ public void registerAtStart(TodoItem it) {
+ it.ownerDeque = this;
+ deque.addFirst(it);
}
- public static void registerAtStart(Collection<? extends TodoItem> them) {
- todoDeque.addAll(0, them);
+ public void registerAtStart(Collection<? extends TodoItem> them) {
+ for ( TodoItem it : them )
+ it.ownerDeque = this;
+ deque.addAll(0, them);
}
- public static TodoItem removeNext() {
- return todoDeque.poll();
+ public TodoItem removeNext() {
+ return deque.poll();
}
- public static boolean dispatchOne() {
+ public boolean dispatchOne() {
TodoItem it = removeNext();
if ( it != null ) {
+ assert(it.ownerDeque == this);
it.dispatch();
return true;
} else
return false;
}
- public static void dispatchLoop() {
+ public void dispatchLoop() {
while ( dispatchOne() )
;
}