edu.vt.marian.search
Class MaxUnionSearcherWtdObjSetEnum

java.lang.Object
  |
  +--edu.vt.marian.search.MaxUnionSearcherWtdObjSetEnum

public class MaxUnionSearcherWtdObjSetEnum
extends java.lang.Object
implements WtdObjSetEnumeration

A WtdObjSetEnumeration for a MaxUnionSearcher.

See Also:
WtdObjSetEnumeration, MaxUnionSearcher

Field Summary
protected  edu.vt.marian.common.Debug debug
           
protected  int numSeen
          How many elements have we seen already (used to implement *NumRemaining()).
protected  Sequencer seq
          The LinkSearcher works off a collectoon of sets (weighted or unweighted) each linked to a node in a "key" set.
protected  InsertionOrderWtdObjTable tbl
          The linking sets in Sequencer are merged through this Table.
protected  java.util.Enumeration tblEnum
           
protected  edu.vt.marian.common.WtdObj top
          Keep one element cached (if any available).
 
Constructor Summary
MaxUnionSearcherWtdObjSetEnum(Sequencer sequencer, InsertionOrderWtdObjTable table, edu.vt.marian.common.Debug d)
           
 
Method Summary
 int approxNumRemaining()
          Return approximate number of elements left.
 int exactNumRemaining()
          Return exact number of elements remaining in the parent set.
 boolean hasMoreElements()
           
 int maxNumRemaining()
          Return maximum number of elements left.
 java.lang.Object nextElement()
           
 int sample(int num, WtdObjBag sampleBag)
          Copy a certain number of elements into a bag.
 int sampleToWt(edu.vt.marian.common.Weight minWt, WtdObjBag sampleBag)
          Copy into a bag all the members of this set with weights >= some weight.
 void skip(int k)
          Skip forward a certain number of elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected edu.vt.marian.common.Debug debug

seq

protected Sequencer seq
The LinkSearcher works off a collectoon of sets (weighted or unweighted) each linked to a node in a "key" set. The collection of sets is maintained by some form of Sequencer, which is initialized before the Searcher is constructed.

tbl

protected InsertionOrderWtdObjTable tbl
The linking sets in Sequencer are merged through this Table.

tblEnum

protected java.util.Enumeration tblEnum

top

protected edu.vt.marian.common.WtdObj top
Keep one element cached (if any available). This simplifies everything (especially sampleToWt()).

numSeen

protected int numSeen
How many elements have we seen already (used to implement *NumRemaining()).
Constructor Detail

MaxUnionSearcherWtdObjSetEnum

public MaxUnionSearcherWtdObjSetEnum(Sequencer sequencer,
                                     InsertionOrderWtdObjTable table,
                                     edu.vt.marian.common.Debug d)
Method Detail

hasMoreElements

public boolean hasMoreElements()

nextElement

public java.lang.Object nextElement()

skip

public void skip(int k)
Skip forward a certain number of elements.
Specified by:
skip in interface WtdObjSetEnumeration
Parameters:
k - How many elements to skip.
Throws:
java.util.NoSuchElementException -  

sample

public int sample(int num,
                  WtdObjBag sampleBag)
Copy a certain number of elements into a bag.
Specified by:
sample in interface WtdObjSetEnumeration
Parameters:
num - How many elements to copy.
sampleBag - The WtdObjBag to add elements to.
Returns:
OK There were Num elements left, and they all were copied well.
anything else Problems.
Throws:
java.util.NoSuchElementException -  

sampleToWt

public int sampleToWt(edu.vt.marian.common.Weight minWt,
                      WtdObjBag sampleBag)
Copy into a bag all the members of this set with weights >= some weight.
Specified by:
sampleToWt in interface WtdObjSetEnumeration
Parameters:
minWt - The lowest weight to copy.
sampleBag - The WtdObjBag to add elements to.
Returns:
OK There were Num elements left, and they all were copied well.
anything else Problems.
Throws:
java.util.NoSuchElementException -  

exactNumRemaining

public int exactNumRemaining()
Return exact number of elements remaining in the parent set.
Specified by:
exactNumRemaining in interface WtdObjSetEnumeration
Returns:
The exact number of elements still to be enumerated.

approxNumRemaining

public int approxNumRemaining()
Return approximate number of elements left.
Specified by:
approxNumRemaining in interface WtdObjSetEnumeration
Returns:
The approximate number of elements still to be enumerated.

maxNumRemaining

public int maxNumRemaining()
Return maximum number of elements left.
Specified by:
maxNumRemaining in interface WtdObjSetEnumeration
Returns:
The maximum number of elements still to be enumerated.