|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
A WtdObjSetEnumeration is a very light object, many of which can be generated for each WtdObjSet and all of which can execute concurrently in different threads. Provides the java.util.Enumeration functionality and then some.
Synchronization Note: As with all Enumerations in MARIAN, the nextElement()
method in classes implementing this interface should be synchronized,
as should skip(), sample() and sampleToWt(). This prevents concurrency
problems if callers in two different threads are both stepping
through the Enumeration. Now, two callers shouldn't really
be sharing a single Enumeration, but it does happen, and a lack of
synchronization in that circumstance could be terrible. On the other
hand, it does no good to synchronize hasMoreElements(), since in the
moment between calling hasMoreElements() and nextElement() anything
can happen. So for full threadability, one should always use:
try
{ while(TRUE) ... nextElement() ... }
catch( NoSuchElementException e ) {}
rather than:
while( hasMoreElements() )
{ ... nextElement() ... }
Enumeration,
WtdObjSet| Method Summary | |
int |
approxNumRemaining()
Return approximate number of elements left. |
int |
exactNumRemaining()
Return exact number of elements remaining in the parent set. |
int |
maxNumRemaining()
Return maximum number of elements left. |
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 interface java.util.Enumeration |
hasMoreElements,
nextElement |
| Method Detail |
public void skip(int k)
k - How many elements to skip.
public int sample(int num,
WtdObjBag sampleBag)
num - How many elements to copy.sampleBag - The WtdObjBag to add elements to.
public int sampleToWt(edu.vt.marian.common.Weight minWt,
WtdObjBag sampleBag)
minWt - The lowest weight to copy.sampleBag - The WtdObjBag to add elements to.public int exactNumRemaining()
public int approxNumRemaining()
public int maxNumRemaining()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||