com.partnersoft.data
Class CountingBag

java.lang.Object
  extended by com.partnersoft.data.CountingBag

public class CountingBag
extends java.lang.Object

A HashMap which can hold multiple copies of objects. Tracks the number of objects.


Constructor Summary
CountingBag()
           
 
Method Summary
 int add(java.lang.Object ob)
          Adds an object.
 int add(java.lang.Object ob, int quantity)
          Adds an object several times.
 int count(java.lang.Object ob)
          Get # of instances.
 java.util.Map getCounts()
           
 void setCounts(java.util.Map newCounts)
           
 java.util.Iterator uniqueElements()
          Get unique elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountingBag

public CountingBag()
Method Detail

add

public int add(java.lang.Object ob)
Adds an object.


add

public int add(java.lang.Object ob,
               int quantity)
Adds an object several times.


count

public int count(java.lang.Object ob)
Get # of instances.


uniqueElements

public java.util.Iterator uniqueElements()
Get unique elements.


getCounts

public java.util.Map getCounts()

setCounts

public void setCounts(java.util.Map newCounts)