Class LongRedBlackTree

  • All Implemented Interfaces:
    java.io.Serializable

    public class LongRedBlackTree
    extends java.lang.Object
    implements java.io.Serializable
    Container class for storing objects sorted on a long key. Uses the RedBlack Tree algorithm to store the objects.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(long key)
      Returns true if the key is in the set.
      java.lang.Object get​(long key)
      Returns the object value for the given key or null if the key is not in the tree set.
      java.lang.Object getAtOrAfter​(long key)
      Returns the value object for the smallest key in the set that is greater than or equal to the given key.
      java.lang.Object getAtOrBefore​(long key)
      Returns the value object for the largest key in the set that is less than or equal to the given key.
      long getFirst()
      Returns the first key in this set.
      long getLast()
      Returns the last key in this set.
      long getNext​(long key)
      Returns the smallest key in the set that is greater than the given key.
      long getPrevious​(long key)
      Returns the largest key in the set that is less than the given key.
      boolean isEmpty()
      Test if the set is empty.
      java.util.Iterator<?> iterator()
      Returns an iterator over all the objects stored in this tree.
      void put​(long key, java.lang.Object obj)
      Adds the given key,value pair to this tree.
      java.lang.Object remove​(long key)
      Removes the given key from the set.
      void removeAll()
      Removes all keys from the set.
      int size()
      Returns the number keys in this set.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LongRedBlackTree

        public LongRedBlackTree()
    • Method Detail

      • size

        public int size()
        Returns the number keys in this set.
      • containsKey

        public boolean containsKey​(long key)
        Returns true if the key is in the set.
        Parameters:
        key - the key whose presence is to be tested.
      • get

        public java.lang.Object get​(long key)
        Returns the object value for the given key or null if the key is not in the tree set.
        Parameters:
        key - the key whose associated value is to be returned.
      • getAtOrAfter

        public java.lang.Object getAtOrAfter​(long key)
        Returns the value object for the smallest key in the set that is greater than or equal to the given key. Returns -1 if there are no keys greater than or equal to the given key.
        Parameters:
        key - the search key.
      • getAtOrBefore

        public java.lang.Object getAtOrBefore​(long key)
        Returns the value object for the largest key in the set that is less than or equal to the given key. Returns -1 if there are no keys less than or equal to the given key.
        Parameters:
        key - the search key.
      • getNext

        public long getNext​(long key)
                     throws NoSuchIndexException
        Returns the smallest key in the set that is greater than the given key.
        Parameters:
        key - the search key.
        Throws:
        NoSuchIndexException - thrown if no keys exist in this tree past the given key.
      • getPrevious

        public long getPrevious​(long key)
                         throws NoSuchIndexException
        Returns the largest key in the set that is less than the given key. Returns -1 if there are not keys less than the given key.
        Parameters:
        key - the search key.
        Throws:
        NoSuchIndexException - thrown if no keys exist in this tree before the given key.
      • put

        public void put​(long key,
                        java.lang.Object obj)
        Adds the given key,value pair to this tree.
        Parameters:
        key - the key with which the object is to be associated.
        obj - object to be associated with the specified key.
      • remove

        public java.lang.Object remove​(long key)
        Removes the given key from the set.
        Parameters:
        key - key whose mapping is to be removed from the map.
      • removeAll

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

        public boolean isEmpty()
        Test if the set is empty.
        Returns:
        true if the set is empty.
      • iterator

        public java.util.Iterator<?> iterator()
        Returns an iterator over all the objects stored in this tree.