mark.nlp.data
Class ArrayBag

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

public class ArrayBag
extends java.lang.Object
implements Bag

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


Constructor Summary
ArrayBag(ObjectMap v)
           
 
Method Summary
 void inc(java.lang.Object o, double cnt)
           
 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

ArrayBag

public ArrayBag(ObjectMap v)
Method Detail

inc

public void inc(java.lang.Object o,
                double cnt)

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.