Class BoundedList<E>

All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess, SequencedCollection<E>

public class BoundedList<E> extends ArrayList<E>
ArrayList with minimum and maximum sizes. For each operation, the size is checked and the BoundedList to ensure that it is kept in the range. Created: 10 juin 2005
Author:
Arnaud Thimel - thimel@codelutin.com
See Also:
  • Constructor Details

    • BoundedList

      public BoundedList(int initialCapacity)
      Creates a new BoundedList with the specified initialCapacity. The min size is set to 0 and the max size to the infinite.
      Parameters:
      initialCapacity - FIXME
    • BoundedList

      public BoundedList()
      Creates a new BoundedList with the default capacity. The min size is set to 0 and the max size to the infinite.
    • BoundedList

      public BoundedList(Collection<E> arg0)
      Creates a new BoundedList with the specified collection of elements. The min size is set to 0 and the max size to the infinite.
      Parameters:
      arg0 - FIXME
    • BoundedList

      public BoundedList(int minSize, int maxSize)
      Creates a new empty BoundedList with the specified min and max sizes. Please be informed that -1 represents the infinite.
      Parameters:
      minSize - FIXME
      maxSize - FIXME
  • Method Details

    • isFull

      public boolean isFull()
      Indicates if the list size is at the maximum
      Returns:
      true is the maximum size has been reached
    • isToMinimum

      public boolean isToMinimum()
      Indicates if the list size is to the minimum
      Returns:
      true is the list size is the minimum size
    • add

      public boolean add(E o)
      Appends the specified element to the end of this list.
      Specified by:
      add in interface Collection<E>
      Specified by:
      add in interface List<E>
      Overrides:
      add in class ArrayList<E>
      Parameters:
      o - the Object to be added
    • add

      public void add(int index, E o)
      Inserts the specified element at the specified position in this list.
      Specified by:
      add in interface List<E>
      Overrides:
      add in class ArrayList<E>
      Parameters:
      index - the position where to add the Object
      o - the Object to be added
    • addAll

      public boolean addAll(Collection<? extends E> c)
      Appends all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator.
      Specified by:
      addAll in interface Collection<E>
      Specified by:
      addAll in interface List<E>
      Overrides:
      addAll in class ArrayList<E>
      Parameters:
      c - the collection of Objects to be added
    • addAll

      public boolean addAll(int index, Collection<? extends E> c)
      Inserts all of the elements in the specified Collection into this list, starting at the specified position.
      Specified by:
      addAll in interface List<E>
      Overrides:
      addAll in class ArrayList<E>
      Parameters:
      index - the index where to start adding the collection of objects
      c - the collection of Objects to be added
    • clone

      public Object clone()
      Returns a shallow copy of this BoundedList instance
      Overrides:
      clone in class ArrayList<E>
    • remove

      public E remove(int index)
      Removes the element at the specified position in this list.
      Specified by:
      remove in interface List<E>
      Overrides:
      remove in class ArrayList<E>
      Parameters:
      index - the position of the element to be removed
    • removeRange

      protected void removeRange(int fromIndex, int toIndex)
      Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.
      Overrides:
      removeRange in class ArrayList<E>
      Parameters:
      fromIndex - index of first element to be removed
      toIndex - index after last element to be removed
    • remove

      public boolean remove(Object o)
      Removes a single instance of the specified element from this list, if it is present (optional operation).
      Specified by:
      remove in interface Collection<E>
      Specified by:
      remove in interface List<E>
      Overrides:
      remove in class ArrayList<E>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Removes from this collection all of its elements that are contained in the specified collection (optional operation).
      Specified by:
      removeAll in interface Collection<E>
      Specified by:
      removeAll in interface List<E>
      Overrides:
      removeAll in class ArrayList<E>
    • toString

      public String toString()
      Overrides:
      toString in class AbstractCollection<E>