summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-11 00:24:52 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-11 00:24:52 +0100
commit7df51c33f5a486a967a2550fdcf7664af1678dd2 (patch)
treeb5ead2eaa93e9fd43687a6de3ca51c6f975de2c6 /core/src/ch/asynk/rustanddust
parente893d9f9a99517b2b2191db80be4d18d88e29dcf (diff)
downloadRustAndDust-7df51c33f5a486a967a2550fdcf7664af1678dd2.zip
RustAndDust-7df51c33f5a486a967a2550fdcf7664af1678dd2.tar.gz
SearchBoard: use ArrayListIt
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/SearchBoard.java27
1 files changed, 11 insertions, 16 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
index 0fc4c9a..9fd06ad 100644
--- a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
+++ b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
@@ -1,9 +1,6 @@
package ch.asynk.rustanddust.engine;
import java.util.List;
-import java.util.LinkedList;
-import java.util.ArrayDeque;
-import java.util.Iterator;
import java.util.Collection;
import ch.asynk.rustanddust.engine.util.ArrayListIt;
@@ -38,10 +35,10 @@ public class SearchBoard
private int searchCount;
private Node nodes[];
- private ArrayDeque<Node> stack;
- private LinkedList<Node> queue;
- private ArrayDeque<Node> roadMarch;
- private List<Node> los;
+ private ArrayListIt<Node> stack;
+ private ArrayListIt<Node> queue;
+ private ArrayListIt<Node> roadMarch;
+ private ArrayListIt<Node> los;
private boolean losBlocked;
public SearchBoard(Board board, int cols, int rows)
@@ -58,9 +55,9 @@ public class SearchBoard
nodes[i + (j * cols)] = new Node((i + dx), j);
}
- this.queue = new LinkedList<Node>();
- this.stack = new ArrayDeque<Node>(20);
- this.roadMarch = new ArrayDeque<Node>(5);
+ this.queue = new ArrayListIt<Node>(30);
+ this.stack = new ArrayListIt<Node>(20);
+ this.roadMarch = new ArrayListIt<Node>(5);
this.los = new ArrayListIt<Node>(10);
}
@@ -283,10 +280,10 @@ public class SearchBoard
if (range <= 0)
return targets.size();
- queue.add(from);
+ queue.enqueue(from);
while (queue.size() != 0) {
- Node src = queue.remove();
+ Node src = queue.dequeue();
if (src.remaining <= 0)
continue;
@@ -305,12 +302,10 @@ public class SearchBoard
dst.search = searchCount;
dst.remaining = rangeLeft;
- queue.add(dst);
+ queue.enqueue(dst);
Tile t = getTile(dst);
if (!t.isEmpty() && hasClearLineOfSight(from, dst, angle)) {
- Iterator<Pawn> it = t.iterator();
- while (it.hasNext()) {
- Pawn target = it.next();
+ for (Pawn target : t) {
if (shooter.canEngage(target))
targets.add(target);
}