A healthy dash of google-collections

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5798 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Dave Hoover
2009-05-23 01:04:08 +00:00
parent 1bdb2cae16
commit b222eed2fd
34 changed files with 152 additions and 91 deletions
@@ -3,6 +3,9 @@ package com.threerings.util;
import java.util.ArrayList;
import java.util.HashMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
/**
* Maintains a bidirectional graph to manage the order that the items are removed. Children
* must wait until their parents are accessed - thus removing an available element means that
@@ -96,8 +99,8 @@ public class DependencyGraph<T>
DependencyNode<T> node1 = _nodes.get(elem1);
DependencyNode<T> node2 = _nodes.get(elem2);
ArrayList<DependencyNode<T>> nodesToCheck = new ArrayList<DependencyNode<T>>();
ArrayList<DependencyNode<T>> nodesAlreadyChecked = new ArrayList<DependencyNode<T>>();
ArrayList<DependencyNode<T>> nodesToCheck = Lists.newArrayList();
ArrayList<DependencyNode<T>> nodesAlreadyChecked = Lists.newArrayList();
nodesToCheck.addAll(node1.parents);
// We prevent circular dependencies when we add dependencies. Otherwise, this'd be
@@ -124,10 +127,10 @@ public class DependencyGraph<T>
}
/** All the nodes included in the graph. */
protected HashMap<T, DependencyNode<T>> _nodes = new HashMap<T, DependencyNode<T>>();
protected HashMap<T, DependencyNode<T>> _nodes = Maps.newHashMap();
/** Nodes in the graph with no parents/dependencies. */
protected ArrayList<T> _orphans = new ArrayList<T>();
protected ArrayList<T> _orphans = Lists.newArrayList();
/** Represents a node in our dependency graph. */
protected class DependencyNode<DT>
@@ -139,8 +142,8 @@ public class DependencyGraph<T>
public DependencyNode (DT contents)
{
this.content = contents;
this.parents = new ArrayList<DependencyNode<DT>>();
this.children = new ArrayList<DependencyNode<DT>>();
this.parents = Lists.newArrayList();
this.children = Lists.newArrayList();
}
}
}
@@ -26,6 +26,8 @@ import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import com.google.common.collect.Maps;
import com.samskivert.util.StringUtil;
import static com.threerings.NaryaLog.log;
@@ -195,7 +197,7 @@ public class MessageManager
protected ClassLoader _loader;
/** A cache of instantiated message bundles. */
protected HashMap<String, MessageBundle> _cache = new HashMap<String, MessageBundle>();
protected HashMap<String, MessageBundle> _cache = Maps.newHashMap();
/** Our top-level message bundle, from which others obtain messages if
* they can't find them within themselves. */
+3 -1
View File
@@ -23,6 +23,8 @@ package com.threerings.util;
import java.util.ArrayList;
import com.google.common.collect.Lists;
/**
* Utility for times.
*/
@@ -104,7 +106,7 @@ public class TimeUtil
minUnit = (byte) Math.min(minUnit, MAX_UNIT);
duration = Math.abs(duration);
ArrayList<String> list = new ArrayList<String>();
ArrayList<String> list = Lists.newArrayList();
int parts = 0; // how many parts are in the translation string?
for (byte uu = MILLISECOND; uu <= MAX_UNIT; uu++) {
int quantity = getQuantityPerUnit(uu);