com.threerings.stats.data
Class IntSetStat

java.lang.Object
  extended by com.threerings.stats.data.Stat
      extended by com.threerings.stats.data.SetStat<Integer>
          extended by com.threerings.stats.data.IntSetStat
All Implemented Interfaces:
Streamable, DSet.Entry, Cloneable

public class IntSetStat
extends SetStat<Integer>

Used to track a statistic comprised of a bounded set of integers.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.stats.data.Stat
Stat.AuxDataSource, Stat.Type
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
Streamable.Closure
 
Field Summary
protected  StreamableArrayIntSet _intSet
           
protected  int _maxSize
           
protected static int MAX_MAX_SIZE
           
 
Fields inherited from class com.threerings.stats.data.Stat
_codeToType, _crc, _modCount, _modified, _type
 
Constructor Summary
IntSetStat()
          Constructs a new IntSetStat that will store up to 255 ints.
IntSetStat(int maxSize)
          Constructs a new IntSetStat that will store up to maxSize ints.
 
Method Summary
 boolean add(Integer key)
          Adds the specified int to this set.
 boolean contains(Integer key)
          Returns true if the specified int is contained in this set.
 void persistTo(ObjectOutputStream out, Stat.AuxDataSource aux)
          Serializes this instance for storage in the item database.
 int size()
          Returns the number of values stored in the set.
 void unpersistFrom(ObjectInputStream in, Stat.AuxDataSource aux)
          Unserializes this item from data obtained from the item database.
 String valueToString()
          Derived statistics must override this method and render their value to a string.
 
Methods inherited from class com.threerings.stats.data.Stat
clone, crc32, getCode, getKey, getModCount, getType, getType, initType, isModified, setModCount, setModified, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_maxSize

protected int _maxSize

_intSet

protected StreamableArrayIntSet _intSet

MAX_MAX_SIZE

protected static final int MAX_MAX_SIZE
See Also:
Constant Field Values
Constructor Detail

IntSetStat

public IntSetStat()
Constructs a new IntSetStat that will store up to 255 ints.


IntSetStat

public IntSetStat(int maxSize)
Constructs a new IntSetStat that will store up to maxSize ints.

Parameters:
maxSize - the maximum number of ints to store in the IntSetStat. Must be <= 255.
Method Detail

size

public int size()
Returns the number of values stored in the set.

Specified by:
size in class SetStat<Integer>

contains

public boolean contains(Integer key)
Returns true if the specified int is contained in this set.

Specified by:
contains in class SetStat<Integer>

add

public boolean add(Integer key)
Adds the specified int to this set.

Specified by:
add in class SetStat<Integer>
Returns:
true if the int was newly added, false if it was already contained in the set, or if the set is full.

persistTo

public void persistTo(ObjectOutputStream out,
                      Stat.AuxDataSource aux)
               throws IOException
Description copied from class: Stat
Serializes this instance for storage in the item database. Derived classes must override this method to implement persistence.

Specified by:
persistTo in class Stat
Throws:
IOException

unpersistFrom

public void unpersistFrom(ObjectInputStream in,
                          Stat.AuxDataSource aux)
                   throws IOException,
                          ClassNotFoundException
Description copied from class: Stat
Unserializes this item from data obtained from the item database. Derived classes must override this method to implement persistence.

Specified by:
unpersistFrom in class Stat
Throws:
IOException
ClassNotFoundException

valueToString

public String valueToString()
Description copied from class: Stat
Derived statistics must override this method and render their value to a string. Used by Stat.toString() and to display the value in game.

Specified by:
valueToString in class Stat