Interface Index

All Superinterfaces:
AutoCloseable, Iterable<Long>, com.fishlib.base.log.LogOutputAppendable, LongSizedDataStructure, OrderedKeys, ReadOnlyIndex, SafeCloseable
All Known Implementing Classes:
CurrentOnlyIndex, SortedIndex, TreeIndex

public interface Index extends ReadOnlyIndex, com.fishlib.base.log.LogOutputAppendable, Iterable<Long>, LongSizedDataStructure
A set of sorted long keys between 0 and Long.MAX_VALUE
  • Field Details

    • USE_PRIORITY_QUEUE_RANDOM_BUILDER

      static final boolean USE_PRIORITY_QUEUE_RANDOM_BUILDER
    • BAD_RANGES_AS_ERROR

      static final boolean BAD_RANGES_AS_ERROR
    • FACTORY

      static final Index.Factory FACTORY
      A Factory that creates Indexs that support previous values.
    • CURRENT_FACTORY

      static final Index.Factory CURRENT_FACTORY
      A Factory that creates Indexs that support only current values.
  • Method Details

    • insert

      void insert(long key)
      Add a single key to this index if it's not already present.
      Parameters:
      key - The key to add
    • insertRange

      void insertRange(long startKey, long endKey)
      Add all keys in a closed range to this index if they are not already present.
      Parameters:
      startKey - The first key to add
      endKey - The last key to add (inclusive)
    • insert

      void insert(LongChunk<Attributes.OrderedKeyIndices> keys, int offset, int length)
      Add all of the (ordered) keys in a slice of keys to this index if they are not already present.
      Parameters:
      keys - The LongChunk of Attributes.OrderedKeyIndices to insert
      offset - The offset in keys to begin inserting keys from
      length - The number of keys to insert
    • insert

      void insert(ReadOnlyIndex added)
      Add all of the keys in added to this index if they are not already present.
      Parameters:
      added - The index to add
    • remove

      void remove(long key)
      Remove a single key from this index if it's present.
      Parameters:
      key - The key to remove
    • removeRange

      void removeRange(long startKey, long endKey)
      Remove all keys in a closed range from this index if they are present.
      Parameters:
      startKey - The first key to remove
      endKey - The last key to remove (inclusive)
    • remove

      void remove(LongChunk<Attributes.OrderedKeyIndices> keys, int offset, int length)
      Remove all of the (ordered) keys in a slice of keys from this index if they are present.
      Parameters:
      keys - The LongChunk of Attributes.OrderedKeyIndices to remove
      offset - The offset in keys to begin removing keys from
      length - The number of keys to remove
    • remove

      void remove(ReadOnlyIndex removed)
      Remove all of the keys in removed that are present in this index.
      Parameters:
      removed - The index to remove
    • update

      void update(ReadOnlyIndex added, ReadOnlyIndex removed)
      Simultaneously adds the keys from the first index and removes the keys from the second one. API assumption: the intersection of added and removed is empty.
    • extract

      @NotNull default Index extract(@NotNull Index other)
      Removes all the keys from other index that are present in the current set.
      Returns:
      a new index representing the keys removed
    • retain

      void retain(ReadOnlyIndex indexToIntersect)
      Modifies the index by removing any keys not in the indexToIntersect argument.
      Parameters:
      indexToIntersect - an index with the keys to retain; any other keys not in indexToIntersect will be removed.
    • retainRange

      void retainRange(long start, long end)
      Modifies the index by keeping only keys in the interval [start, end]
      Parameters:
      start - beginning of interval of keys to keep.
      end - end of interval of keys to keep (inclusive).
    • clear

      void clear()
    • shiftInPlace

      void shiftInPlace(long shiftAmount)
    • insertWithShift

      void insertWithShift(long shiftAmount, ReadOnlyIndex other)
      For each key in the provided index, shift it by shiftAmount and insert it in the current index.
      Parameters:
      shiftAmount - the amount to add to each key in the index argument before insertion.
      other - the index with the keys to shift and insert.
    • compact

      void compact()
      May reclaim some unused memory.
    • initializePreviousValue

      void initializePreviousValue()
      Initializes our previous value from the current value. This call is used by operations that manipulate an Index while constructing it, but need to set the state at the end of the initial operation to the current state. Calling this in other circumstances will yield undefined results.