Class CircularLinkedList<E>

All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>

public class CircularLinkedList<E> extends LinkedList<E>
A LinkedList with size constraints. When at maxCapacity and an element is added, the eldest element is removed.
See Also:
  • Field Details

    • maxCapacity

      private int maxCapacity
  • Constructor Details

    • CircularLinkedList

      public CircularLinkedList(int maxCapacity)
  • Method Details

    • setMaxCapacity

      public void setMaxCapacity(int maxCapacity)
    • getMaxCapacity

      public int getMaxCapacity()
    • isFull

      public boolean isFull()
    • addFirst

      public void addFirst(E e)
      Specified by:
      addFirst in interface Deque<E>
      Overrides:
      addFirst in class LinkedList<E>
    • addLast

      public void addLast(E e)
      Specified by:
      addLast in interface Deque<E>
      Overrides:
      addLast in class LinkedList<E>
    • add

      public boolean add(E e)
      Specified by:
      add in interface Collection<E>
      Specified by:
      add in interface Deque<E>
      Specified by:
      add in interface List<E>
      Specified by:
      add in interface Queue<E>
      Overrides:
      add in class LinkedList<E>
    • addAll

      public boolean addAll(Collection<? extends E> c)
      Specified by:
      addAll in interface Collection<E>
      Specified by:
      addAll in interface Deque<E>
      Specified by:
      addAll in interface List<E>
      Overrides:
      addAll in class LinkedList<E>
    • addAll

      public boolean addAll(int index, Collection<? extends E> c)
      Specified by:
      addAll in interface List<E>
      Overrides:
      addAll in class LinkedList<E>
    • add

      public void add(int i, E e)
      Specified by:
      add in interface List<E>
      Overrides:
      add in class LinkedList<E>
    • makeRoom

      private void makeRoom()
      Makes a space available if the list is already full. Calling this prior the insertion avoids that the list exceeds its limits.
    • houseKeep

      private void houseKeep()
      Makes the list fit its limits by removing last items in cases where the list might have exceeded its limits.