Class SortedIntList<E>

  • Type Parameters:
    E -
    All Implemented Interfaces:
    java.lang.Iterable<SortedIntList.Node<E>>

    public class SortedIntList<E>
    extends java.lang.Object
    implements java.lang.Iterable<SortedIntList.Node<E>>
    A sorted double linked list which uses ints for indexing
    • Constructor Summary

      Constructors 
      Constructor Description
      SortedIntList()
      Creates an ascending list
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears list
      E get​(int index)
      Retrieves an element at a given index
      E insert​(int index, E value)
      Inserts an element into the list at the given index
      boolean isEmpty()
      Returns true if the list is empty.
      java.util.Iterator<SortedIntList.Node<E>> iterator()
      Returns an iterator to traverse the list.
      boolean notEmpty()
      Returns true if the list has one or more items.
      int size()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • SortedIntList

        public SortedIntList()
        Creates an ascending list
    • Method Detail

      • insert

        @Null
        public E insert​(int index,
                        E value)
        Inserts an element into the list at the given index
        Parameters:
        index - Index of the element
        value - Element to insert
        Returns:
        Element replaced by newly inserted element, null if nothing was replaced
      • get

        public E get​(int index)
        Retrieves an element at a given index
        Parameters:
        index - Index of the element to retrieve
        Returns:
        Matching element, null otherwise
      • clear

        public void clear()
        Clears list
      • size

        public int size()
        Returns:
        size of list equal to elements contained in it
      • notEmpty

        public boolean notEmpty()
        Returns true if the list has one or more items.
      • isEmpty

        public boolean isEmpty()
        Returns true if the list is empty.
      • iterator

        public java.util.Iterator<SortedIntList.Node<E>> iterator()
        Returns an iterator to traverse the list.

        If Collections.allocateIterators is false, the same iterator instance is returned each time this method is called. Use the SortedIntList.Iterator constructor for nested or multithreaded iteration.

        Specified by:
        iterator in interface java.lang.Iterable<E>