Class RwListWrapper<T>

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

public class RwListWrapper<T> extends Object implements List<T>, IRwDataStructure
  • Field Details

    • list

      protected List<T> list
      The wrapped list.
  • Constructor Details

    • RwListWrapper

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

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

    • getAutoLock

      public jadex.common.RwAutoLock getAutoLock()
      Gets the internal auto lock.
      Specified by:
      getAutoLock in interface IRwDataStructure
      Returns:
      The lock.
    • size

      public int size()
      Returns the list size.
      Specified by:
      size in interface Collection<T>
      Specified by:
      size in interface List<T>
      Returns:
      The list size.
    • isEmpty

      public boolean isEmpty()
      Returns if the list is empty.
      Specified by:
      isEmpty in interface Collection<T>
      Specified by:
      isEmpty in interface List<T>
      Returns:
      True, if the list is empty.
    • contains

      public boolean contains(Object o)
      Returns if the list contains an object.
      Specified by:
      contains in interface Collection<T>
      Specified by:
      contains in interface List<T>
      Returns:
      True, if the list contains an object.
    • iterator

      public Iterator<T> iterator()
      Returns the iterator. Warning: Use manual locking.
      Specified by:
      iterator in interface Collection<T>
      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface List<T>
      Returns:
      The iterator.
    • toArray

      public Object[] toArray()
      Returns the list elements as an array.
      Specified by:
      toArray in interface Collection<T>
      Specified by:
      toArray in interface List<T>
      Returns:
      The list elements as an array.
    • toArray

      public <T> T[] toArray(T[] a)
      Returns the list elements as an array.
      Specified by:
      toArray in interface Collection<T>
      Specified by:
      toArray in interface List<T>
      Parameters:
      a - Array (type) to use.
      Returns:
      The list elements as an array.
    • add

      public boolean add(T e)
      Appends an element to the list.
      Specified by:
      add in interface Collection<T>
      Specified by:
      add in interface List<T>
      Parameters:
      e - The element.
      Returns:
      True.
    • remove

      public boolean remove(Object o)
      Removes an element from the list.
      Specified by:
      remove in interface Collection<T>
      Specified by:
      remove in interface List<T>
      Parameters:
      e - The element.
      Returns:
      True, if an element was removed.
    • containsAll

      public boolean containsAll(Collection<?> c)
      Returns if all elements of a collection are contained.
      Specified by:
      containsAll in interface Collection<T>
      Specified by:
      containsAll in interface List<T>
      Parameters:
      c - The collection.
      Returns:
      True, if all elements are contained in the list.
    • addAll

      public boolean addAll(Collection<? extends T> c)
      Appends all elements of a collection.
      Specified by:
      addAll in interface Collection<T>
      Specified by:
      addAll in interface List<T>
      Parameters:
      c - The collection.
      Returns:
      True.
    • addAll

      public boolean addAll(int index, Collection<? extends T> c)
      Appends all elements of a collection, starting at the specified position.
      Specified by:
      addAll in interface List<T>
      Parameters:
      index - Index where to start.
      c - The collection.
      Returns:
      True.
    • removeAll

      public boolean removeAll(Collection<?> c)
      Removes all elements of a collection contained in the list.
      Specified by:
      removeAll in interface Collection<T>
      Specified by:
      removeAll in interface List<T>
      Parameters:
      c - The collection.
      Returns:
      True, if the collection has changed.
    • retainAll

      public boolean retainAll(Collection<?> c)
      Retains all elements contained in the list also contained in a collection .
      Specified by:
      retainAll in interface Collection<T>
      Specified by:
      retainAll in interface List<T>
      Parameters:
      c - The collection.
      Returns:
      True, if the collection has changed.
    • clear

      public void clear()
      Clears the list.
      Specified by:
      clear in interface Collection<T>
      Specified by:
      clear in interface List<T>
    • get

      public T get(int index)
      Gets an indexed element from the list.
      Specified by:
      get in interface List<T>
      Parameters:
      index - Index of the element.
      Returns:
      Indexed element.
    • set

      public T set(int index, T element)
      Sets an indexed element in the list.
      Specified by:
      set in interface List<T>
      Parameters:
      index - Index of the element.
      element - Indexed element.
      Returns:
      Element previously at the position.
    • add

      public void add(int index, T element)
      Inserts an element at a position.
      Specified by:
      add in interface List<T>
      Parameters:
      index - Index of the element.
      element - The element.
    • remove

      public T remove(int index)
      Removes an indexed element from the list.
      Specified by:
      remove in interface List<T>
      Parameters:
      index - Index of the element.
      Returns:
      Indexed element.
    • indexOf

      public int indexOf(Object o)
      Returns the index of the first occurrence of an element.
      Specified by:
      indexOf in interface List<T>
      Parameters:
      o - Object to be found.
      Returns:
      Found position or -1 if not found.
    • lastIndexOf

      public int lastIndexOf(Object o)
      Returns the index of the last occurrence of an element.
      Specified by:
      lastIndexOf in interface List<T>
      Parameters:
      o - Object to be found.
      Returns:
      Found position or -1 if not found.
    • listIterator

      public ListIterator<T> listIterator()
      Returns the list iterator. Warning: Use manual locking.
      Specified by:
      listIterator in interface List<T>
      Returns:
      The list iterator.
    • listIterator

      public ListIterator<T> listIterator(int index)
      Returns the list iterator starting at a position. Warning: Use manual locking.
      Specified by:
      listIterator in interface List<T>
      Returns:
      The list iterator.
    • subList

      public List<T> subList(int fromindex, int toindex)
      Returns a view of the list. Warning: Use manual locking.
      Specified by:
      subList in interface List<T>
      Parameters:
      fromindex - Start position.
      toindex - End position.
      Returns:
      View of the list.