/** * */ package net.varkhan.base.containers.queue; import net.varkhan.base.containers.Iterator; import net.varkhan.base.containers.type.FloatVisitable; /** * <b>A modifiable set of elements maintaining an internal order</b> * <p/> * A queue provides insertions, inspection and extraction operations * on its elements, that follow the internal order, and may be subject to * implementation-specific restrictions (bounds, delays, unicity...). * <p/> * * @author varkhan * @date Mar 13, 2009 * @time 5:24:34 AM */ public interface FloatQueue extends Queue<Float>, FloatVisitable { /********************************************************************************** ** Queue statistics accessors **/ /** * Return the number of entries in the queue * * @return the number of objects stored in the queue */ public long size(); /** * Removes all objects from the queue */ public void clear(); /********************************************************************************** ** Queue element operations **/ /** * Adds an object on the queue. * * @param obj the object to add * * @return {@literal true} if the object was added, {@literal false} if * the object could not be added (for instance, because a limit on the * queue content has been reached) */ public boolean add(Float obj); /** * Adds an object on the queue. * * @param obj the object to add * * @return {@literal true} if the object was added, {@literal false} if * the object could not be added (for instance, because a limit on the * queue content has been reached) */ public boolean add(float obj); /** * Removes and return the object at the beginning of the queue * * @return the biggest object on the queue */ public Float poll(); /** * Removes and return the object at the beginning of the queue * * @return the biggest object on the queue */ public float pollFloat(); /** * Returns, without removing it, the object at the beginning of the queue * * @return the biggest object on the queue */ public Float peek(); /** * Returns, without removing it, the object at the beginning of the queue * * @return the biggest object on the queue */ public float peekFloat(); /** * Returns an element at a given position * * @param pos the position in the queue * * @return the element at position {@code pos} */ public Float get(int pos); /** * Returns an element at a given position * * @param pos the position in the queue * * @return the element at position {@code pos} */ public float getFloat(int pos); /********************************************************************************** ** Iterator operations **/ /** * Returns an iterator over the elements in the queue. * * @return an Iterator. */ public Iterator<Float> iterator(); /** * Iterate over each element of the queue, and pass it as argument to a * visitor's {@link Visitor#invoke} method, until this method returns * a negative count. * * @param vis the visitor * @param par the control parameter * @param <Par> the type of the control parameter * * @return the sum of all positive return values from the visitor */ public <Par> long visit(Visitor<Float,Par> vis, Par par); /** * Iterate over each element of the queue, and pass it as argument to a * visitor's {@link Visitor#invoke} method, until this method returns * a negative count. * * @param vis the visitor * @param par the control parameter * @param <Par> the type of the control parameter * * @return the sum of all positive return values from the visitor */ public <Par> long visit(FloatVisitor<Par> vis, Par par); }