Class RwLinkedListWrapper<T>

java.lang.Object
jadex.collection.RwListWrapper<T>
jadex.collection.RwLinkedListWrapper<T>
All Implemented Interfaces:
IRwDataStructure, Iterable<T>, Collection<T>, Deque<T>, List<T>, Queue<T>, SequencedCollection<T>

public class RwLinkedListWrapper<T> extends RwListWrapper<T> implements Deque<T>
  • Constructor Details

    • RwLinkedListWrapper

      public RwLinkedListWrapper(LinkedList<T> list)
      Creates the list wrapper.
      Parameters:
      list - The wrapped List.
    • RwLinkedListWrapper

      public RwLinkedListWrapper(LinkedList<T> list, ReadWriteLock lock)
      Creates the list wrapper with a specific internal lock.
      Parameters:
      list - The wrapped List.
  • Method Details

    • removeLast

      public T removeLast()
      Removes the last element in the list.
      Specified by:
      removeLast in interface Deque<T>
      Specified by:
      removeLast in interface List<T>
      Specified by:
      removeLast in interface SequencedCollection<T>
      Returns:
      Element remove from list.
    • addFirst

      public void addFirst(T e)
      Adds an element to the beginning of the list.
      Specified by:
      addFirst in interface Deque<T>
      Specified by:
      addFirst in interface List<T>
      Specified by:
      addFirst in interface SequencedCollection<T>
      Parameters:
      e - The Element
    • addLast

      public void addLast(T e)
      Adds an element to the end of the list.
      Specified by:
      addLast in interface Deque<T>
      Specified by:
      addLast in interface List<T>
      Specified by:
      addLast in interface SequencedCollection<T>
      Parameters:
      e - The Element
    • offerFirst

      public boolean offerFirst(T e)
      Adds the element at the end unless it would violate capacity restrictions.
      Specified by:
      offerFirst in interface Deque<T>
      Parameters:
      e - The element.
      Returns:
      True, if the element was added.
    • offerLast

      public boolean offerLast(T e)
      Adds the element at the end unless it would violate capacity restrictions.
      Specified by:
      offerLast in interface Deque<T>
      Parameters:
      e - The element.
      Returns:
      True, if the element was added.
    • removeFirst

      public T removeFirst()
      Removes the element from the beginning.
      Specified by:
      removeFirst in interface Deque<T>
      Specified by:
      removeFirst in interface List<T>
      Specified by:
      removeFirst in interface SequencedCollection<T>
      Returns:
      The element that was removed.
    • pollFirst

      public T pollFirst()
      Removes the element from the beginning, returns null if this list is empty.
      Specified by:
      pollFirst in interface Deque<T>
      Returns:
      The element that was removed or null.
    • pollLast

      public T pollLast()
      Removes the element from the end, returns null if this list is empty.
      Specified by:
      pollLast in interface Deque<T>
      Returns:
      The element that was removed or null.
    • getFirst

      public T getFirst()
      Gets first list element.
      Specified by:
      getFirst in interface Deque<T>
      Specified by:
      getFirst in interface List<T>
      Specified by:
      getFirst in interface SequencedCollection<T>
      Returns:
      The element.
    • getLast

      public T getLast()
      Gets last list element.
      Specified by:
      getLast in interface Deque<T>
      Specified by:
      getLast in interface List<T>
      Specified by:
      getLast in interface SequencedCollection<T>
      Returns:
      The element.
    • peekFirst

      public T peekFirst()
      Gets first list element.
      Specified by:
      peekFirst in interface Deque<T>
      Returns:
      The element, null if list is empty.
    • peekLast

      public T peekLast()
      Gets last list element.
      Specified by:
      peekLast in interface Deque<T>
      Returns:
      The element, null if list is empty.
    • removeFirstOccurrence

      public boolean removeFirstOccurrence(Object o)
      Removes the first occurrence of an element.
      Specified by:
      removeFirstOccurrence in interface Deque<T>
      Parameters:
      o - Object being removed
      Returns:
      True, if removed.
    • removeLastOccurrence

      public boolean removeLastOccurrence(Object o)
      Removes the last occurrence of an element.
      Specified by:
      removeLastOccurrence in interface Deque<T>
      Parameters:
      o - Object being removed
      Returns:
      True, if removed.
    • offer

      public boolean offer(T e)
      Inserts the specified element.
      Specified by:
      offer in interface Deque<T>
      Specified by:
      offer in interface Queue<T>
      Parameters:
      e - The element.
      Returns:
      True if the element was added.
    • remove

      public T remove()
      Removes an element from the head of the list.
      Specified by:
      remove in interface Deque<T>
      Specified by:
      remove in interface Queue<T>
      Returns:
      The element.
    • poll

      public T poll()
      Removes an element from the head of the list.
      Specified by:
      poll in interface Deque<T>
      Specified by:
      poll in interface Queue<T>
      Returns:
      The element or null if empty.
    • element

      public T element()
      Gets an element from the head of the list.
      Specified by:
      element in interface Deque<T>
      Specified by:
      element in interface Queue<T>
      Returns:
      The element.
    • peek

      public T peek()
      Gets an element from the head of the list.
      Specified by:
      peek in interface Deque<T>
      Specified by:
      peek in interface Queue<T>
      Returns:
      The element, null if empty.
    • push

      public void push(T e)
      Pushes an element to the head of the list.
      Specified by:
      push in interface Deque<T>
      Parameters:
      e - The element.
    • pop

      public T pop()
      Pops an element from the head of the list.
      Specified by:
      pop in interface Deque<T>
      Returns:
      The element.
    • descendingIterator

      public Iterator<T> descendingIterator()
      Specified by:
      descendingIterator in interface Deque<T>
    • reversed

      public LinkedList<T> reversed()
      Unimplemented, here to resolve default method conflict in Java 21 while avoiding reimplementation of functionality in Java 17.
      Specified by:
      reversed in interface Deque<T>
      Specified by:
      reversed in interface List<T>
      Specified by:
      reversed in interface SequencedCollection<T>