Class BoundedList<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<E>
org.nuiton.util.BoundedList<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess

public class BoundedList<E>
extends java.util.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:
Serialized Form
  • Field Summary

    Fields inherited from class java.util.AbstractList

    modCount
  • Constructor Summary

    Constructors 
    Constructor Description
    BoundedList()
    Creates a new BoundedList with the default capacity.
    BoundedList​(int initialCapacity)
    Creates a new BoundedList with the specified initialCapacity.
    BoundedList​(int minSize, int maxSize)
    Creates a new empty BoundedList with the specified min and max sizes.
    BoundedList​(java.util.Collection<E> arg0)
    Creates a new BoundedList with the specified collection of elements.
  • Method Summary

    Modifier and Type Method Description
    void add​(int index, E o)
    Inserts the specified element at the specified position in this list.
    boolean add​(E o)
    Appends the specified element to the end of this list.
    boolean addAll​(int index, java.util.Collection<? extends E> c)
    Inserts all of the elements in the specified Collection into this list, starting at the specified position.
    boolean addAll​(java.util.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.
    java.lang.Object clone()
    Returns a shallow copy of this BoundedList instance
    boolean isFull()
    Indicates if the list size is at the maximum
    boolean isToMinimum()
    Indicates if the list size is to the minimum
    E remove​(int index)
    Removes the element at the specified position in this list.
    boolean remove​(java.lang.Object o)
    Removes a single instance of the specified element from this list, if it is present (optional operation).
    boolean removeAll​(java.util.Collection<?> c)
    Removes from this collection all of its elements that are contained in the specified collection (optional operation).
    protected void removeRange​(int fromIndex, int toIndex)
    Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.
    java.lang.String toString()  

    Methods inherited from class java.util.ArrayList

    clear, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeIf, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize

    Methods inherited from class java.util.AbstractCollection

    containsAll

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Collection

    parallelStream, stream, toArray

    Methods inherited from interface java.util.List

    containsAll
  • 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​(java.util.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 java.util.Collection<E>
      Specified by:
      add in interface java.util.List<E>
      Overrides:
      add in class java.util.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 java.util.List<E>
      Overrides:
      add in class java.util.ArrayList<E>
      Parameters:
      index - the position where to add the Object
      o - the Object to be added
    • addAll

      public boolean addAll​(java.util.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 java.util.Collection<E>
      Specified by:
      addAll in interface java.util.List<E>
      Overrides:
      addAll in class java.util.ArrayList<E>
      Parameters:
      c - the collection of Objects to be added
    • addAll

      public boolean addAll​(int index, java.util.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 java.util.List<E>
      Overrides:
      addAll in class java.util.ArrayList<E>
      Parameters:
      index - the index where to start adding the collection of objects
      c - the collection of Objects to be added
    • clone

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

      public E remove​(int index)
      Removes the element at the specified position in this list.
      Specified by:
      remove in interface java.util.List<E>
      Overrides:
      remove in class java.util.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 java.util.ArrayList<E>
      Parameters:
      fromIndex - index of first element to be removed
      toIndex - index after last element to be removed
    • remove

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

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

      public java.lang.String toString()
      Overrides:
      toString in class java.util.AbstractCollection<E>