Skip to content

Commit 88d1e59

Browse files
author
bytekeeper
committed
Replaced Index with int.
1 parent f0e80be commit 88d1e59

File tree

3 files changed

+15
-78
lines changed

3 files changed

+15
-78
lines changed

src/main/java/bwem/ChokePointImpl.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import bwem.tile.MiniTile;
2020
import bwem.tile.MiniTileImpl;
2121
import bwem.typedef.CPPath;
22-
import bwem.typedef.Index;
2322
import bwem.unit.Neutral;
2423
import java.util.ArrayList;
2524
import java.util.List;
@@ -28,7 +27,7 @@
2827
public class ChokePointImpl implements ChokePoint {
2928
private final Graph graph;
3029
private final boolean isPseudo;
31-
private final Index index;
30+
private final int index;
3231
private final Pair<Area, Area> areas;
3332
private final WalkPosition[] nodes;
3433
private final List<Pair<WalkPosition, WalkPosition>> nodesInArea;
@@ -39,7 +38,7 @@ public class ChokePointImpl implements ChokePoint {
3938

4039
ChokePointImpl(
4140
final Graph graph,
42-
final Index index,
41+
final int index,
4342
final Area area1,
4443
final Area area2,
4544
final List<WalkPosition> geometry,
@@ -129,7 +128,7 @@ > getMap().getData().getMiniTile(geometry.get(i)).getAltitude().intValue())) {
129128

130129
ChokePointImpl(
131130
final Graph graph,
132-
final Index index,
131+
final int index,
133132
final Area area1,
134133
final Area area2,
135134
final List<WalkPosition> geometry) {
@@ -224,7 +223,7 @@ public void onBlockingNeutralDestroyed(final Neutral pBlocking) {
224223
}
225224
}
226225

227-
Index getIndex() {
226+
int getIndex() {
228227
return this.index;
229228
}
230229

src/main/java/bwem/Graph.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import bwem.tile.TileImpl;
2828
import bwem.typedef.Altitude;
2929
import bwem.typedef.CPPath;
30-
import bwem.typedef.Index;
3130
import bwem.unit.Geyser;
3231
import bwem.unit.Mineral;
3332
import bwem.unit.Neutral;
@@ -152,16 +151,16 @@ private List<ChokePoint> getChokePoints(final Area a, final Area b) {
152151
// Returns the ground distance in pixels between cpA->center() and cpB>center()
153152
public int distance(ChokePoint cpA, ChokePoint cpB) {
154153
return chokePointDistanceMatrix
155-
.get(((ChokePointImpl) cpA).getIndex().intValue())
156-
.get(((ChokePointImpl) cpB).getIndex().intValue());
154+
.get(((ChokePointImpl) cpA).getIndex())
155+
.get(((ChokePointImpl) cpB).getIndex());
157156
}
158157

159158
// Returns a list of getChokePoints, which is intended to be the shortest walking path from cpA to
160159
// cpB.
161160
public CPPath getPath(ChokePoint cpA, ChokePoint cpB) {
162161
return pathsBetweenChokePoints
163-
.get(((ChokePointImpl) cpA).getIndex().intValue())
164-
.get(((ChokePointImpl) cpB).getIndex().intValue());
162+
.get(((ChokePointImpl) cpA).getIndex())
163+
.get(((ChokePointImpl) cpB).getIndex());
165164
}
166165

167166
public CPPath getPath(final Position a, final Position b, final MutableInt pLength) {
@@ -326,8 +325,7 @@ public void createChokePoints(
326325
final List<StaticBuilding> staticBuildings,
327326
final List<Mineral> minerals,
328327
final List<Pair<Pair<AreaId, AreaId>, WalkPosition>> rawFrontier) {
329-
Index newIndex = new Index(0);
330-
328+
int newIndex = 0;
331329
final List<Neutral> blockingNeutrals = new ArrayList<>();
332330
for (final StaticBuilding s : staticBuildings) {
333331
if (s.isBlocking()) {
@@ -418,7 +416,7 @@ public void createChokePoints(
418416
for (final List<WalkPosition> cluster : clusters) {
419417
getChokePoints(a, b)
420418
.add(new ChokePointImpl(this, newIndex, getArea(a), getArea(b), cluster));
421-
newIndex = newIndex.add(1);
419+
newIndex++;
422420
}
423421
}
424422

@@ -447,7 +445,7 @@ public void createChokePoints(
447445
.add(
448446
new ChokePointImpl(
449447
this, newIndex, blockedAreaA, blockedAreaB, list, blockingNeutral));
450-
newIndex = newIndex.add(1);
448+
newIndex++;
451449
}
452450
}
453451
}
@@ -758,15 +756,15 @@ private void updateGroupIds() {
758756
}
759757

760758
private void setDistance(final ChokePoint cpA, final ChokePoint cpB, final int value) {
761-
final int indexA = ((ChokePointImpl) cpA).getIndex().intValue();
762-
final int indexB = ((ChokePointImpl) cpB).getIndex().intValue();
759+
final int indexA = ((ChokePointImpl) cpA).getIndex();
760+
final int indexB = ((ChokePointImpl) cpB).getIndex();
763761
this.chokePointDistanceMatrix.get(indexA).set(indexB, value);
764762
this.chokePointDistanceMatrix.get(indexB).set(indexA, value);
765763
}
766764

767765
private void setPath(final ChokePoint cpA, final ChokePoint cpB, final CPPath pathAB) {
768-
final int indexA = ((ChokePointImpl) cpA).getIndex().intValue();
769-
final int indexB = ((ChokePointImpl) cpB).getIndex().intValue();
766+
final int indexA = ((ChokePointImpl) cpA).getIndex();
767+
final int indexB = ((ChokePointImpl) cpB).getIndex();
770768

771769
this.pathsBetweenChokePoints.get(indexA).set(indexB, pathAB);
772770

src/main/java/bwem/typedef/Index.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)