Interface ShortKeySet

All Known Implementing Classes:
BitTree, FullKeySet, RedBlackKeySet

public interface ShortKeySet
The ShortKeySet provides an interface for managing a set of ordered short keys between the values of 0 and N. It can add keys, remove keys, find the next key greater than some value , and find the previous key less than some value.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    containsKey(short key)
    Determines if a given key is in the set.
    short
    Returns the first (lowest) key in the set.
    short
    Returns the last (highest) key in the set.
    short
    getNext(short key)
    finds the next key that is in the set that is greater than the given key.
    short
    getPrevious(short key)
    finds the previous key that is in the set that is less than the given key.
    boolean
    Checks if the set is empty.
    void
    put(short key)
    Adds a key to the set.
    boolean
    remove(short key)
    Removes the key from the set.
    void
    Removes all keys from the set.
    int
    Returns the number of keys currently in the set.
  • Method Details

    • size

      int size()
      Returns the number of keys currently in the set.
    • containsKey

      boolean containsKey(short key)
      Determines if a given key is in the set.
      Parameters:
      key - the key whose presence is to be tested.
      Returns:
      true if the key is in the set.
    • getFirst

      short getFirst()
      Returns the first (lowest) key in the set.
    • getLast

      short getLast()
      Returns the last (highest) key in the set.
    • put

      void put(short key)
      Adds a key to the set.
      Parameters:
      key - the key to add to the set.
    • remove

      boolean remove(short key)
      Removes the key from the set.
      Parameters:
      key - the key to remove from the set.
    • removeAll

      void removeAll()
      Removes all keys from the set.
    • getNext

      short getNext(short key)
      finds the next key that is in the set that is greater than the given key.
      Parameters:
      key - the key for which to find the next key after.
    • getPrevious

      short getPrevious(short key)
      finds the previous key that is in the set that is less than the given key.
      Parameters:
      key - the key for which to find the previous key.
    • isEmpty

      boolean isEmpty()
      Checks if the set is empty.
      Returns:
      true if the set is empty.