mark.nlp.data
Class HashBag

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

public class HashBag
extends java.lang.Object
implements Bag

A Bag implemented with a hash. Appropriate when one does not know the possible elements of the bag ahead of time (or the number of possibilities is prohibitively large compared to what will actually happen).


Field Summary
protected  java.util.HashMap fCounts
           
protected  int fNum
           
 
Constructor Summary
HashBag()
           
 
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
 

Field Detail

fCounts

protected java.util.HashMap fCounts

fNum

protected int fNum
Constructor Detail

HashBag

public HashBag()
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.