Interface OffsetQueue<T>
-
- Type Parameters:
T
- the type of the items stored in the queue
public interface OffsetQueue<T>
A queue ofT
items indexed by offsets. The items are ordered in the queue according to their offset. The item with the smallest offset is the head of the queue. The item with the largest offset is the tail of the queue.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
getHeadItem()
Return the item with the smallest offset in the queue.Iterable<T>
getHeadItems(int skip, int limit)
Return #limit items after skipping #skip items from the queue.long
getHeadOffset()
T
getItem(long offset)
Return the item at the given #offset.OffsetQueue<T>
getMinOffsetQueue(long minOffset)
Return anOffsetQueue
offset queue which contains all the items from the current queue at an offset greater or equal to #minOffset.int
getSize()
long
getTailOffset()
boolean
isEmpty()
void
putItem(long offset, T item)
Put an item in the queue at the given offset.void
putItems(OffsetQueue<T> offsetQueue)
Put all the items from the #offsetQueue in this queue.
-
-
-
Method Detail
-
putItem
void putItem(long offset, T item)
Put an item in the queue at the given offset.- Parameters:
offset
- the offset associated to the itemitem
- the item to be stored at the given offset
-
putItems
void putItems(OffsetQueue<T> offsetQueue)
Put all the items from the #offsetQueue in this queue.- Parameters:
offsetQueue
- the queue to be merged into this queue
-
getItem
@CheckForNull T getItem(long offset)
Return the item at the given #offset.- Parameters:
offset
- the offset of the item to be returned- Returns:
- the item ; or
null
if no item could be found at the given offset
-
getHeadItem
@CheckForNull T getHeadItem()
Return the item with the smallest offset in the queue.- Returns:
- the first item in the queue ; or
null
if the queue is empty
-
getHeadItems
@Nonnull Iterable<T> getHeadItems(int skip, int limit)
Return #limit items after skipping #skip items from the queue.- Parameters:
skip
- the number of items to skiplimit
- the maximum number of items to return. -1 will return all items.- Returns:
- an iterable containing the items
-
getHeadOffset
long getHeadOffset()
- Returns:
- the smallest offset stored in the queue ; or
-1
if the queue is empty.
-
getTailOffset
long getTailOffset()
- Returns:
- the largest offset stored in the queue ; or
-1
if the queue is empty.
-
isEmpty
boolean isEmpty()
- Returns:
true
if the queue is empty ;false
otherwise
-
getSize
int getSize()
- Returns:
- the number of items in the queue
-
getMinOffsetQueue
@Nonnull OffsetQueue<T> getMinOffsetQueue(long minOffset)
Return anOffsetQueue
offset queue which contains all the items from the current queue at an offset greater or equal to #minOffset.- Parameters:
minOffset
- the minimal offset of the items in the returned offset queue- Returns:
- the offset queue
-
-