blob: 037723b33c6608ba4049b723d8fdad34a7ccf55d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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<? extends TodoItem> them) {
todoDeque.addAll(them);
}
public static void registerAtStart(TodoItem it) {
todoDeque.addFirst(it);
}
public static void registerAtStart(Collection<? extends 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() )
;
}
}
|