Last active
December 14, 2015 14:09
MergingQueue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A merging FIFO queue. The entries are merged on a key and so the queue interface | |
* is not appropriate. Note that the FIFO applies to the keys, not the values. | |
* | |
* @author nitsanw | |
* | |
* @param <KEY> | |
* @param <VAL> | |
*/ | |
public interface MergingQueue<KEY, VAL> { | |
/** | |
* Removed the tail entry of the queue and returns it. | |
* | |
* @return the latest value for the oldest key in the queue, or null if queue is empty. | |
*/ | |
VAL poll(); | |
/** | |
* Inserts a new entry to the queue. If a value for this key already exists then the | |
* original order is preserved while the value is replaced. | |
* | |
* @param key not null | |
* @param val not null | |
*/ | |
void offer(KEY key, VAL val); | |
/** | |
* @return true if queue is empty, false otherwise | |
*/ | |
boolean isEmpty(); | |
/** | |
* Clears the queue of all entries | |
*/ | |
void clear(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment