hold gamemanagers in a set instead of a list since their order doesn't matter

and we want to prevent them from being added twice.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1284 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2002-04-19 21:33:21 +00:00
parent 4b0b462c3a
commit 575c276c9a
@@ -1,10 +1,10 @@
// //
// $Id: AIGameTicker.java,v 1.1 2002/04/19 18:33:32 ray Exp $ // $Id: AIGameTicker.java,v 1.2 2002/04/19 21:33:21 ray Exp $
package com.threerings.parlor.game; package com.threerings.parlor.game;
import java.util.Iterator; import java.util.Iterator;
import java.util.ArrayList; import java.util.HashSet;
import com.samskivert.util.Interval; import com.samskivert.util.Interval;
import com.samskivert.util.IntervalManager; import com.samskivert.util.IntervalManager;
@@ -42,7 +42,7 @@ public class AIGameTicker implements Interval, Runnable
*/ */
private AIGameTicker () private AIGameTicker ()
{ {
_games = new ArrayList(); _games = new HashSet();
_id = IntervalManager.register(this, TICK_FREQUENCY, null, true); _id = IntervalManager.register(this, TICK_FREQUENCY, null, true);
} }
@@ -64,8 +64,8 @@ public class AIGameTicker implements Interval, Runnable
{ {
_games.remove(mgr); _games.remove(mgr);
// if there aren't any AIs, let's // if there aren't any AIs, let's stop running
if (_games.size() == 0) { if (_games.isEmpty()) {
_ticker = null; _ticker = null;
IntervalManager.remove(_id); IntervalManager.remove(_id);
} }
@@ -88,8 +88,8 @@ public class AIGameTicker implements Interval, Runnable
} }
} }
/** Our list of ai games. */ /** Our set of ai games. */
protected ArrayList _games; protected HashSet _games;
/** Our interval id. */ /** Our interval id. */
protected int _id; protected int _id;