Code hygiene. Not as pedantic as I'd like, but I couldn't resist the huge time

saver that is Eclipse's "Infer generic types" which leaves HashMap and
ArrayList as the declared type where I would normally prefer to change those to
Map and List and use Maps and Lists to instantiate them.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@593 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Michael Bayne
2008-08-01 15:56:37 +00:00
parent 60622c3590
commit 659f5bc5e2
64 changed files with 393 additions and 388 deletions
@@ -408,7 +408,7 @@ public class AStarPathUtil
* A class that represents a single traversable node in the tile array
* along with its current A*-specific search information.
*/
protected static class Node implements Comparable
protected static class Node implements Comparable<Node>
{
/** The node coordinates. */
public int x, y;
@@ -435,9 +435,9 @@ public class AStarPathUtil
id = _nextid++;
}
public int compareTo (Object o)
public int compareTo (Node o)
{
int bf = ((Node)o).f;
int bf = o.f;
// since the set contract is fulfilled using the equality results
// returned here, and we'd like to allow multiple nodes with
@@ -446,7 +446,7 @@ public class AStarPathUtil
// unique node id since it will return a consistent ordering for
// the objects.
if (f == bf) {
return (this == o) ? 0 : (id - ((Node)o).id);
return (this == o) ? 0 : (id - o.id);
}
return f - bf;
@@ -84,7 +84,7 @@ public class LineSegmentPath
* Constructs a line segment path with the specified list of points.
* An arbitrary direction will be assigned to the starting node.
*/
public LineSegmentPath (List points)
public LineSegmentPath (List<Point> points)
{
createPath(points);
}
@@ -331,12 +331,12 @@ public class LineSegmentPath
* its starting position to the given destination coordinates
* following the given list of screen coordinates.
*/
protected void createPath (List points)
protected void createPath (List<Point> points)
{
Point last = null;
int size = points.size();
for (int ii = 0; ii < size; ii++) {
Point p = (Point)points.get(ii);
Point p = points.get(ii);
int dir = (ii == 0) ? NORTH : DirectionUtil.getDirection(last, p);
addNode(p.x, p.y, dir);
@@ -349,14 +349,14 @@ public class LineSegmentPath
*/
protected PathNode getNextNode ()
{
return (PathNode)_niter.next();
return _niter.next();
}
/** The nodes that make up the path. */
protected ArrayList<PathNode> _nodes = new ArrayList<PathNode>();
/** We use this when moving along this path. */
protected Iterator _niter;
protected Iterator<PathNode> _niter;
/** When moving, the pathable's source path node. */
protected PathNode _src;
@@ -41,17 +41,14 @@ public class ModeUtil
* desired mode is also used.
*/
public static DisplayMode getDisplayMode (
GraphicsDevice gd, int width, int height,
int desiredDepth, int minimumDepth)
GraphicsDevice gd, int width, int height, int desiredDepth, int minimumDepth)
{
DisplayMode[] modes = gd.getDisplayModes();
final int ddepth = desiredDepth;
// we sort modes in order of desirability
Comparator mcomp = new Comparator () {
public int compare (Object o1, Object o2) {
DisplayMode m1 = (DisplayMode)o1;
DisplayMode m2 = (DisplayMode)o2;
Comparator<DisplayMode> mcomp = new Comparator<DisplayMode>() {
public int compare (DisplayMode m1, DisplayMode m2) {
int bd1 = m1.getBitDepth(), bd2 = m2.getBitDepth();
int rr1 = m1.getRefreshRate(), rr2 = m2.getRefreshRate();
@@ -73,7 +70,7 @@ public class ModeUtil
};
// but we only add modes that meet our minimum requirements
TreeSet mset = new TreeSet(mcomp);
TreeSet<DisplayMode> mset = new TreeSet<DisplayMode>(mcomp);
for (int i = 0; i < modes.length; i++) {
if (modes[i].getWidth() == width &&
modes[i].getHeight() == height &&
@@ -83,7 +80,7 @@ public class ModeUtil
}
}
return (mset.size() > 0) ? (DisplayMode)mset.first() : null;
return (mset.size() > 0) ? mset.first() : null;
}
/**
@@ -40,7 +40,7 @@ public class PathSequence
*/
public PathSequence (Path first, Path second)
{
this(new ArrayList());
this(new ArrayList<Path>());
_paths.add(first);
_paths.add(second);
}
@@ -50,7 +50,7 @@ public class PathSequence
* Note: Paths may be added to the end of the list while
* the pathable is still traversing earlier paths!
*/
public PathSequence (List paths)
public PathSequence (List<Path> paths)
{
_paths = paths;
}
@@ -119,7 +119,7 @@ public class PathSequence
_pable.pathCompleted(tickStamp);
} else {
_curPath = (Path) _paths.remove(0);
_curPath = _paths.remove(0);
_lastInit = initStamp;
_curPath.init(_pableRep, initStamp);
@@ -128,7 +128,7 @@ public class PathSequence
}
/** The list of paths. */
protected List _paths;
protected List<Path> _paths;
/** The timestamp at which we last inited a path. */
protected long _lastInit;
@@ -22,6 +22,9 @@
package com.threerings.media.util;
import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.Maps;
import com.threerings.media.timer.MediaTimer;
import com.threerings.media.timer.NanoTimer;
@@ -58,10 +61,10 @@ public class PerformanceMonitor
public static void register (PerformanceObserver obs, String name, long delta)
{
// get the observer's action hashtable
HashMap actions = (HashMap)_observers.get(obs);
Map<String, PerformanceAction> actions = _observers.get(obs);
if (actions == null) {
// create it if it didn't exist
_observers.put(obs, actions = new HashMap());
_observers.put(obs, actions = new HashMap<String, PerformanceAction>());
}
// add the action to the set we're tracking
@@ -77,7 +80,7 @@ public class PerformanceMonitor
public static void unregister (PerformanceObserver obs, String name)
{
// get the observer's action hashtable
HashMap actions = (HashMap)_observers.get(obs);
Map<String, PerformanceAction> actions = _observers.get(obs);
if (actions == null) {
log.warning("Attempt to unregister by unknown observer " +
"[observer=" + obs + ", name=" + name + "].");
@@ -85,7 +88,7 @@ public class PerformanceMonitor
}
// attempt to remove the specified action
PerformanceAction action = (PerformanceAction)actions.remove(name);
PerformanceAction action = actions.remove(name);
if (action == null) {
log.warning("Attempt to unregister unknown action " +
"[observer=" + obs + ", name=" + name + "].");
@@ -108,7 +111,7 @@ public class PerformanceMonitor
public static void tick (PerformanceObserver obs, String name)
{
// get the observer's action hashtable
HashMap actions = (HashMap)_observers.get(obs);
Map<String, PerformanceAction> actions = _observers.get(obs);
if (actions == null) {
log.warning("Attempt to tick by unknown observer " +
"[observer=" + obs + ", name=" + name + "].");
@@ -116,7 +119,7 @@ public class PerformanceMonitor
}
// get the specified action
PerformanceAction action = (PerformanceAction)actions.get(name);
PerformanceAction action = actions.get(name);
if (action == null) {
log.warning("Attempt to tick unknown value " +
"[observer=" + obs + ", name=" + name + "].");
@@ -144,7 +147,8 @@ public class PerformanceMonitor
}
/** The observers monitoring some set of actions. */
protected static HashMap _observers = new HashMap();
protected static Map<PerformanceObserver, Map<String, PerformanceAction>> _observers =
Maps.newHashMap();
/** Used to obtain high resolution time stamps. */
protected static MediaTimer _timer = new NanoTimer();