Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/org/andengine/util/algorithm/path/astar/AStarPathFinder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.andengine.util.algorithm.path.astar;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import org.andengine.util.adt.list.ShiftList;
import org.andengine.util.adt.map.LongSparseArray;
import org.andengine.util.adt.queue.IQueue;
Expand Down Expand Up @@ -185,7 +188,7 @@ public Path findPath(final IPathFinderMap<T> pPathFinderMap, final int pXMin, fi
// Inner and Anonymous Classes
// ===========================================================

private static final class Node implements Comparable<Node> {
public static final class Node implements Comparable<Node> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make this public?

// ===========================================================
// Constants
// ===========================================================
Expand Down Expand Up @@ -264,7 +267,9 @@ public String toString() {
// ===========================================================
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method needs to extremely quick, and should not allocate any object!


public static long calculateID(final int pX, final int pY) {
return (((long)pX) << 32) | pY;
final ByteBuffer byteBuffer = ByteBuffer.allocateDirect(16);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
return byteBuffer.putInt(pX).putInt(pY).getLong(0);
}

public boolean equals(final Node pNode) {
Expand All @@ -275,4 +280,4 @@ public boolean equals(final Node pNode) {
// Inner and Anonymous Classes
// ===========================================================
}
}
}