mark.nlp.data
Class SparseBag

java.lang.Object
  |
  +--mark.nlp.data.SparseBag
All Implemented Interfaces:
Bag

public class SparseBag
extends java.lang.Object
implements Bag

A bag implemented with a sparse array. Appropriate when the possible elements of the bag are known ahead of time and the set of elements is sparse.


Constructor Summary
SparseBag(Bag contents, ObjectMap vocabulary)
           
 
Method Summary
 java.util.Iterator iterator()
          Returns an iterator over the object types.
 double num()
          Returns the number of object occurrences in the bag.
 double num(java.lang.Object o)
          Returns the number of object type o occurrences in the bag.
 int numTypes()
          Returns the number of object types with non-zero occurrences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseBag

public SparseBag(Bag contents,
                 ObjectMap vocabulary)
Method Detail

numTypes

public int numTypes()
Description copied from interface: Bag
Returns the number of object types with non-zero occurrences.

Specified by:
numTypes in interface Bag
Returns:
the number of object types with non-zero occurrences.

iterator

public java.util.Iterator iterator()
Description copied from interface: Bag
Returns an iterator over the object types.

Specified by:
iterator in interface Bag
Returns:
the iterator.

num

public double num(java.lang.Object o)
Description copied from interface: Bag
Returns the number of object type o occurrences in the bag.

Specified by:
num in interface Bag
Parameters:
o - the object.
Returns:
the number of o occurrences.

num

public double num()
Description copied from interface: Bag
Returns the number of object occurrences in the bag.

Specified by:
num in interface Bag
Returns:
the number of object occurrences.