Interface ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
- All Known Implementing Classes:
TreeOrderedSetCache
- Enclosing class:
- ForStDBCachingPriorityQueueSet<E extends HeapPriorityQueueElement>
public static interface ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Cache that is organized as an ordered set for byte-arrays. The byte-arrays are sorted in lexicographic order of their content. Caches typically have a bounded size.
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<byte[]>
LEXICOGRAPHIC_BYTE_COMPARATOR
Comparator for byte arrays.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
add(byte[] toAdd)
Adds the given element, if it was not already contained.void
bulkLoadFromOrderedIterator(Iterator<byte[]> orderedIterator)
Clears the cache and adds up tomaxSize()
elements from the iterator to the cache.boolean
isEmpty()
Returnssize() == 0
.boolean
isFull()
Returnssize() == maxSize()
.int
maxSize()
Returns the maximum number of elements that can be stored in the cache.byte[]
peekFirst()
Returns the first element ornull
if empty.byte[]
peekLast()
Returns the last element ornull
if empty.byte[]
pollFirst()
Returns and removes the first element or returnsnull
if empty.byte[]
pollLast()
Returns and removes the last element or returnsnull
if empty.boolean
remove(byte[] toRemove)
Removes the given element, if it is contained.int
size()
Returns the number of contained elements.
-
-
-
Field Detail
-
LEXICOGRAPHIC_BYTE_COMPARATOR
static final Comparator<byte[]> LEXICOGRAPHIC_BYTE_COMPARATOR
Comparator for byte arrays.
-
-
Method Detail
-
size
int size()
Returns the number of contained elements.
-
maxSize
int maxSize()
Returns the maximum number of elements that can be stored in the cache.
-
isEmpty
boolean isEmpty()
Returnssize() == 0
.
-
isFull
boolean isFull()
Returnssize() == maxSize()
.
-
add
boolean add(@Nonnull byte[] toAdd)
Adds the given element, if it was not already contained. Returnstrue
iff the cache was modified.
-
remove
boolean remove(@Nonnull byte[] toRemove)
Removes the given element, if it is contained. Returnstrue
iff the cache was modified.
-
peekFirst
@Nullable byte[] peekFirst()
Returns the first element ornull
if empty.
-
peekLast
@Nullable byte[] peekLast()
Returns the last element ornull
if empty.
-
pollFirst
@Nullable byte[] pollFirst()
Returns and removes the first element or returnsnull
if empty.
-
pollLast
@Nullable byte[] pollLast()
Returns and removes the last element or returnsnull
if empty.
-
bulkLoadFromOrderedIterator
void bulkLoadFromOrderedIterator(@Nonnull Iterator<byte[]> orderedIterator)
Clears the cache and adds up tomaxSize()
elements from the iterator to the cache. Iterator must be ordered in the same order as this cache.- Parameters:
orderedIterator
- iterator with elements in-order.
-
-