utilMDE
Class LimitedSizeIntSet

Object
  extended by LimitedSizeIntSet
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
ValueSet

public class LimitedSizeIntSet
extends Object
implements Serializable, Cloneable

LimitedSizeIntSet stores up to some maximum number of unique non-zero integer values, at which point its rep is nulled, in order to save space.

The advantage of this class over LimitedSizeSet<Integer> is that it does not autobox the int values, so it takes less memory.

See Also:
LimitedSizeSet, Serialized Form

Field Summary
protected  int[] values
           
 
Constructor Summary
LimitedSizeIntSet(int max_values)
           
 
Method Summary
 void add(int elt)
           
 void addAll(LimitedSizeIntSet s)
           
 Object clone()
           
 boolean contains(int elt)
           
 int max_size()
          An upper bound how many distinct elements can be individually represented in the set.
static LimitedSizeIntSet merge(int max_values, List<LimitedSizeIntSet> slist)
          Merges a list of LimitedSizeIntSet objects into a single object that represents the values seen by the entire list.
 boolean repNulled()
           
 int size()
          A lower bound on the number of elements in the set.
 String toString()
           
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

values

protected int[] values
Constructor Detail

LimitedSizeIntSet

public LimitedSizeIntSet(int max_values)
Method Detail

add

public void add(int elt)

addAll

public void addAll(LimitedSizeIntSet s)

contains

public boolean contains(int elt)

size

public int size()
A lower bound on the number of elements in the set. Returns either the number of elements that have been inserted in the set, or max_size(), whichever is less.


max_size

public int max_size()
An upper bound how many distinct elements can be individually represented in the set. Returns max_values+1 (where max_values is the argument to the constructor).


repNulled

public boolean repNulled()

clone

public Object clone()
Overrides:
clone in class Object

merge

public static LimitedSizeIntSet merge(int max_values,
                                      List<LimitedSizeIntSet> slist)
Merges a list of LimitedSizeIntSet objects into a single object that represents the values seen by the entire list. Returns the new object, whose max_values is the given integer.


toString

public String toString()
Overrides:
toString in class Object