Class AvlTree<T>

    • Constructor Detail

      • AvlTree

        public AvlTree()
      • AvlTree

        public AvlTree(Comparator<? super T> comparator)
    • Method Detail

      • insertElement

        public boolean insertElement(T e)
        Insert the specified element into the tree.
      • removeElement

        public boolean removeElement(T e)
        Remove the specified element from the tree if present.
        Returns:
        true if the element was found and removed.
      • clear

        public void clear()
        Removes all elements from the tree.
      • getHeight

        public int getHeight()
        Get the height of the tree.
        Specified by:
        getHeight in interface  Tree<T>
        Returns:
        the height of the tree.
      • size

        public int size()
        Get the number of elements stored in this tree.
        Specified by:
        size in interface  Collection<T>
        Specified by:
        size in interface  List<T>
        Specified by:
        size in interface  Set<T>
        Specified by:
        size in class  AbstractCollection<T>
        Returns:
        the number of elements.
      • containsElement

        public boolean containsElement(T e)
        Test whether this tree stores the specified element.
        Returns:
        true if the specified element is already present in the tree.
      • getElement

        public T getElement(int index)
        Get the element at position index
      • findMin

        public T findMin()
        Find the smallest element stored in this tree.
        Returns:
        the smallest element in this tree or null if this tree does not contain any elements.
      • findMax

        public T findMax()
        Find the biggest element stored in this tree.
        Returns:
        the biggest element in this tree or null if this tree does not contain any elements.
      • elementsAsList

        public List<T> elementsAsList()
        Get all elements stored in this tree as a list.
        Returns:
        a list containing all elements stored in this tree.
      • toFoldedString

        public String toFoldedString()
        Create a printable representation of the tree.
      • checkBalanced

        public boolean checkBalanced()
        Check whether the tree is balanced.
      • add

        public boolean add(T element)
      • contains

        public boolean contains(Object object)
      • remove

        public boolean remove(Object object)
      • comparator

        public Comparator<? super T> comparator()
      • first

        public T first()
      • last

        public T last()
      • subSet

        public SortedSet<T> subSet(T fromElement,
                                   T toElement)
      • add

        public void add(int index,
                        T element)
      • addAll

        public boolean addAll(int index,
                              Collection<? extends T> c)
      • set

        public T set(int index,
                     T element)
      • get

        public T get(int index)
      • remove

        public T remove(int index)
      • indexOf

        public int indexOf(Object o)
      • lastIndexOf

        public int lastIndexOf(Object o)
      • subList

        public List<T> subList(int fromIndex,
                               int toIndex)