package edu.vt.marian.search; import java.util.*; import java.io.*; import edu.vt.marian.common.*; /** * The sort of Sequencer that is used with weighted links. The * keySet is a set of nodes on one side of links in the class, and * map is either LinkClassManager.sinkToSource() or sourceToSinks(). *

* This implementation simply extends PriQueueSequencer by defining the * addSets() method to invoke addSet() repeatedly for every WtdObjSet * created by mapping elements in the key set using the given mapping * function. * * @author Paul Mather * @author Robert France * @version $Id: WeightedSetSequencer.java,v 1.2 2000/03/21 04:54:07 paul Exp $ * @see PriQueueSequencer * @see Sequencer * @see WtdObjSetSequencer * @see java.util.Enumeration */ public class WeightedSetSequencer extends PriQueueSequencer implements WtdObjSetSequencer { /** * Create a sequencer for an unknown number of sets. */ public WeightedSetSequencer(long classSize, Debug d) { super( classSize, d ); } /** * Add a new component set to the Sequencer with no scaling constant. * * @param keySet a weighted object set, each of . * @param map someone who can turn each FullID in keySet into a WtdObjSet. * @return ReturnCodes.OK -- set was added without problems; * anything else -- problems. */ public int addSets(WtdObjSet keySet, WtdObjToSetMapping map) { WtdObjSetEnumeration enum; int returnValue; if (keySet != null && map != null) { // Map every WtdObj in keySet to a WtdObjSet... enum = keySet.elements(); while (enum.hasMoreElements()) { super.addSet( map.map( (WtdObj) enum.nextElement() ) ); } returnValue = ReturnCodes.OK; } else returnValue = ReturnCodes.BAD_PARAMS; return returnValue; } }