From 43df45be1abb284af0136e292a3301054f453bc9 Mon Sep 17 00:00:00 2001 From: Tom Conkling Date: Tue, 15 Jul 2008 20:57:01 +0000 Subject: [PATCH] IntStatSet fixes git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@658 c613c5cb-e716-0410-b11b-feb51c14d237 --- src/java/com/threerings/stats/data/IntSetStat.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/java/com/threerings/stats/data/IntSetStat.java b/src/java/com/threerings/stats/data/IntSetStat.java index 65b1c675..808db5e9 100644 --- a/src/java/com/threerings/stats/data/IntSetStat.java +++ b/src/java/com/threerings/stats/data/IntSetStat.java @@ -13,11 +13,11 @@ import com.threerings.io.ObjectOutputStream; public class IntSetStat extends Stat { /** - * Constructs a new IntSetStat that will store an unbounded number of ints. + * Constructs a new IntSetStat that will store up to Integer.MAX_VALUE ints. */ public IntSetStat () { - _maxSize = -1; + _maxSize = Integer.MAX_VALUE; } /** @@ -51,14 +51,15 @@ public class IntSetStat extends Stat */ public boolean add (int key) { - return (_maxSize < 0 || _intSet.size() < _maxSize ? _intSet.add(key) : false); + return (_intSet.size() < _maxSize ? _intSet.add(key) : false); } @Override public void persistTo (ObjectOutputStream out, AuxDataSource aux) throws IOException { - out.writeByte(_intSet.size()); + out.writeInt(_maxSize); + out.writeInt(_intSet.size()); for (int key : _intSet) { out.writeInt(key); } @@ -68,7 +69,8 @@ public class IntSetStat extends Stat public void unpersistFrom (ObjectInputStream in, AuxDataSource aux) throws IOException, ClassNotFoundException { - int numValues = in.readByte(); + _maxSize = in.readInt(); + int numValues = in.readInt(); _intSet = new HashSet(numValues); for (int ii = 0; ii < numValues; ii++) { _intSet.add(in.readInt());