diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-09 11:51:51 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-09 11:51:51 +0100 |
commit | bb6a234d6631ad5bdf6f43b9ba101d133d3b2ee2 (patch) | |
tree | 75fd9547410eadb8e6bc1fda7d2190e6b1322ec1 /core/src/ch/asynk/rustanddust/engine | |
parent | 1619921f6acda0b328f10b34339c2ffd7f06d238 (diff) | |
download | RustAndDust-bb6a234d6631ad5bdf6f43b9ba101d133d3b2ee2.zip RustAndDust-bb6a234d6631ad5bdf6f43b9ba101d133d3b2ee2.tar.gz |
use ArrayListIt
Diffstat (limited to 'core/src/ch/asynk/rustanddust/engine')
5 files changed, 22 insertions, 20 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/Board.java b/core/src/ch/asynk/rustanddust/engine/Board.java index 6664d47..2e5a0b1 100644 --- a/core/src/ch/asynk/rustanddust/engine/Board.java +++ b/core/src/ch/asynk/rustanddust/engine/Board.java @@ -16,6 +16,7 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Matrix4; +import ch.asynk.rustanddust.engine.util.ArrayListIt; import ch.asynk.rustanddust.engine.gfx.Moveable; import ch.asynk.rustanddust.engine.gfx.Animation; import ch.asynk.rustanddust.engine.gfx.animations.AnimationSequence; @@ -61,7 +62,7 @@ public abstract class Board implements Disposable, Animation private int pawnCount = 0; private int animationCount = 0; private final ArrayList<Animation> animations = new ArrayList<Animation>(2); - private final ArrayList<Animation> nextAnimations = new ArrayList<Animation>(2); + private final ArrayListIt<Animation> nextAnimations = new ArrayListIt<Animation>(10); private final LinkedHashSet<Tile> tilesToDraw = new LinkedHashSet<Tile>(); protected SelectedTile selectedTile; @@ -128,8 +129,8 @@ public abstract class Board implements Disposable, Animation for (int i = 0; i < (this.cols * this.rows); i++) tiles[i].dispose(); tilesToDraw.clear(); - for (int i = 0, n = nextAnimations.size(); i < n; i++) - nextAnimations.get(i).dispose(); + for (Animation a : nextAnimations) + a.dispose(); animations.clear(); for (int i = 0, n = animations.size(); i < n; i++) animations.get(i).dispose(); @@ -263,8 +264,8 @@ public abstract class Board implements Disposable, Animation if (over && (animations.size() == 0)) animationsOver(); - for (int i = 0, n = nextAnimations.size(); i < n; i++) - animations.add(nextAnimations.get(i)); + for (Animation a : nextAnimations) + animations.add(a); nextAnimations.clear(); selectedTile.animate(delta); diff --git a/core/src/ch/asynk/rustanddust/engine/Path.java b/core/src/ch/asynk/rustanddust/engine/Path.java index 44b0a1f..6fd3c47 100644 --- a/core/src/ch/asynk/rustanddust/engine/Path.java +++ b/core/src/ch/asynk/rustanddust/engine/Path.java @@ -1,10 +1,10 @@ package ch.asynk.rustanddust.engine; -import java.util.ArrayList; - import com.badlogic.gdx.utils.Pool; import com.badlogic.gdx.utils.Disposable; +import ch.asynk.rustanddust.engine.util.ArrayListIt; + public class Path implements Disposable, Pool.Poolable { private static final Pool<Path> pathPool = new Pool<Path>() { @@ -29,7 +29,7 @@ public class Path implements Disposable, Pool.Poolable public int cost; public int fitness; public boolean roadMarch; - public ArrayList<Tile> tiles; + public ArrayListIt<Tile> tiles; public Path() { @@ -42,7 +42,7 @@ public class Path implements Disposable, Pool.Poolable protected void init(int size) { if (tiles == null) - tiles = new ArrayList<Tile>(size); + tiles = new ArrayListIt<Tile>(size); else tiles. ensureCapacity(size); cost = -1; diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java index 453583f..6a2b1a2 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java +++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java @@ -1,6 +1,5 @@ package ch.asynk.rustanddust.engine; -import java.util.ArrayList; import java.util.List; import java.util.LinkedList; import java.util.HashSet; @@ -8,6 +7,8 @@ import java.util.LinkedHashSet; import com.badlogic.gdx.utils.Disposable; +import ch.asynk.rustanddust.engine.util.ArrayListIt; + public class PathBuilder implements Disposable { private final Board board; @@ -27,8 +28,8 @@ public class PathBuilder implements Disposable { this.board = board; this.tiles = new LinkedHashSet<Tile>(tSize); - this.stack = new ArrayList<Tile>(stSize); - this.ctrlTiles = new ArrayList<Tile>(ftSize); + this.stack = new ArrayListIt<Tile>(stSize); + this.ctrlTiles = new ArrayListIt<Tile>(ftSize); this.paths = new LinkedList<Path>(); this.filteredPaths = new LinkedList<Path>(); this.to = null; diff --git a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java index f4bfd4c..19fa7a8 100644 --- a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java +++ b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java @@ -1,12 +1,13 @@ package ch.asynk.rustanddust.engine; import java.util.List; -import java.util.ArrayList; import java.util.LinkedList; import java.util.ArrayDeque; import java.util.Iterator; import java.util.Collection; +import ch.asynk.rustanddust.engine.util.ArrayListIt; + public class SearchBoard { public class Node @@ -60,7 +61,7 @@ public class SearchBoard this.queue = new LinkedList<Node>(); this.stack = new ArrayDeque<Node>(20); this.roadMarch = new ArrayDeque<Node>(5); - this.los = new ArrayList<Node>(10); + this.los = new ArrayListIt<Node>(10); } private boolean inMap(int col, int row) diff --git a/core/src/ch/asynk/rustanddust/engine/gfx/animations/AnimationSequence.java b/core/src/ch/asynk/rustanddust/engine/gfx/animations/AnimationSequence.java index fdd1e80..d440adc 100644 --- a/core/src/ch/asynk/rustanddust/engine/gfx/animations/AnimationSequence.java +++ b/core/src/ch/asynk/rustanddust/engine/gfx/animations/AnimationSequence.java @@ -1,16 +1,15 @@ package ch.asynk.rustanddust.engine.gfx.animations; -import java.util.ArrayList; - import com.badlogic.gdx.utils.Pool; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import ch.asynk.rustanddust.engine.gfx.Animation; +import ch.asynk.rustanddust.engine.util.ArrayListIt; public class AnimationSequence implements Animation, Pool.Poolable { - private ArrayList<Animation> animations; + private ArrayListIt<Animation> animations; private static final Pool<AnimationSequence> animationSequencePool = new Pool<AnimationSequence>() { @Override @@ -23,7 +22,7 @@ public class AnimationSequence implements Animation, Pool.Poolable { AnimationSequence seq = animationSequencePool.obtain(); if (seq.animations == null) - seq.animations = new ArrayList<Animation>(capacity); + seq.animations = new ArrayListIt<Animation>(capacity); else seq.animations.ensureCapacity(capacity); @@ -33,8 +32,8 @@ public class AnimationSequence implements Animation, Pool.Poolable @Override public void reset() { - for (int i = 0, n = animations.size(); i < n; i++) - animations.get(i).dispose(); + for (Animation a : animations) + a.dispose(); animations.clear(); } |