Interface FixedIndex<S extends Comparable<S>,T extends FixedIndex.Indexable<S>>

All Known Implementing Classes:
PriorityDequeFixedIndex

public interface FixedIndex<S extends Comparable<S>,T extends FixedIndex.Indexable<S>>
An index that allows queries for items with high scores, but drops items with low scores to make extra space. However, since multiple indices can share the same memory, it may not always be possible to free up space in this index. Implementation are NOT thread-safe unless otherwise specified.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
     
    static interface 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(T item)
    Adds an item to the index.
    int
    Returns the max number of items per block.
    void
    Removes all items.
    Returns the queue of dropped items.
    long
    Returns the number of items that can be added without freeing up space.
    void
    Drops low-scoring items to make more free space, and adds them to the dropped queue.
    Returns the highest score of any currently stored item.
    Removes the highest-scoring item currently stored.
    long
    Returns the number of items currently stored.
  • Method Details

    • blockCapacity

      int blockCapacity()
      Returns the max number of items per block.
    • size

      long size()
      Returns the number of items currently stored.
    • freeSpace

      long freeSpace()
      Returns the number of items that can be added without freeing up space.
    • add

      boolean add(T item)
      Adds an item to the index. Returns true if the item was added, false if there wasn't enough space.
    • highestScore

      S highestScore()
      Returns the highest score of any currently stored item.
    • removeHighest

      T removeHighest()
      Removes the highest-scoring item currently stored.
    • freeUpSpace

      void freeUpSpace()
      Drops low-scoring items to make more free space, and adds them to the dropped queue.
    • dropped

      Deque<T> dropped()
      Returns the queue of dropped items.
    • clear

      void clear()
      Removes all items.