tuples (sorted by priority) which throws away stuff at the end when
it gets larger than bound.
This is an internal class. Do not use outside
SemanticDistanceModel.
SemanticDistanceModel.BoundedPrioQueue
public SemanticDistanceModel.BoundedPrioQueue(int initBound)
- New bounded prio queue
- Parameters:
initBound - the intial bound on the number of elements
SemanticDistanceModel.BoundedPrioQueue
public SemanticDistanceModel.BoundedPrioQueue(InputBuffer buffer)
throws QSException
serialize
public void serialize(OutputBuffer buffer)
- Description copied from interface:
QuickSerializable
- Add the object to the
buffer.
- Specified by:
serialize in interface QuickSerializable
- Parameters:
buffer - the output buffer to add the object to
setBound
public void setBound(int bound)
- Set the max number of elements allowed in the queue.
getBound
public int getBound()
- Get the max number of elements allowed in the queue.
update
public boolean update(SemanticDistanceModel.Tuple tuple)
- Update (or add) the tuple <t,d,num>.
FIXME: Java's fucking stupid TreeSet implementation has no
removeLast/update function, so you MUST remove the tuple from the
queue first, then update it, then add it again using this method.
- Parameters:
tuple - the tuple to update (add if not already in the queue)
- Returns:
- true if the update resulted in some tuple being
removed from the end of the prio queue.
getTuple
public SemanticDistanceModel.Tuple getTuple(QuickSerializable key)
- Get the tuple to type
key
remove
public SemanticDistanceModel.Tuple remove(QuickSerializable key)
- Remove a tuple.
getDistance
public Distance getDistance(QuickSerializable to)
- Get the distance value to type
to. Null if it is not
in the prio queue.
iterator
public Iterator iterator()
- Iterator of tuples in ascending order.
size
public int size()
- Number of elements in the queue
removeLast
public void removeLast()
- Remove the last element in the prio queue
toString
public String toString()
- Warning: this method runs in O(n) time.
- Overrides:
toString in class Object