Class TreeList.AVLNode<E>

  • Enclosing class:
    TreeList<E>

    static class TreeList.AVLNode<E>
    extends Object
    Implements an AVLNode which keeps the offset updated.

    This node contains the real work. TreeList is just there to implement List. The nodes don't know the index of the object they are holding. They do know however their position relative to their parent node. This allows to calculate the index of a node while traversing the tree.

    The Faedelung calculation stores a flag for both the left and right child to indicate if they are a child (false) or a link as in linked list (true).

    • Method Detail

      • getValue

        E getValue()
        Gets the value.
        Returns:
        the value of this node
      • setValue

        void setValue​(E obj)
        Sets the value.
        Parameters:
        obj - the value to store
      • get

        TreeList.AVLNode<E> get​(int index)
        Locate the element with the given index relative to the offset of the parent of this node.
      • indexOf

        int indexOf​(Object object,
                    int index)
        Locate the index that contains the specified object.
      • toArray

        void toArray​(Object[] array,
                     int index)
        Stores the node and its children into the array specified.
        Parameters:
        array - the array to be filled
        index - the index of this node
      • next

        TreeList.AVLNode<E> next()
        Gets the next node in the list after this one.
        Returns:
        the next node
      • previous

        TreeList.AVLNode<E> previous()
        Gets the node in the list before this one.
        Returns:
        the previous node
      • insert

        TreeList.AVLNode<E> insert​(int index,
                                   E obj)
        Inserts a node at the position index.
        Parameters:
        index - is the index of the position relative to the position of the parent node.
        obj - is the object to be stored in the position.
      • remove

        TreeList.AVLNode<E> remove​(int index)
        Removes the node at a given position.
        Parameters:
        index - is the index of the element to be removed relative to the position of the parent node of the current node.