Package org.nuiton.util
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
-
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 voidadd(int index, E o)Inserts the specified element at the specified position in this list.booleanadd(E o)Appends the specified element to the end of this list.booleanaddAll(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.booleanaddAll(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.Objectclone()Returns a shallow copy of this BoundedList instancebooleanisFull()Indicates if the list size is at the maximumbooleanisToMinimum()Indicates if the list size is to the minimumEremove(int index)Removes the element at the specified position in this list.booleanremove(java.lang.Object o)Removes a single instance of the specified element from this list, if it is present (optional operation).booleanremoveAll(java.util.Collection<?> c)Removes from this collection all of its elements that are contained in the specified collection (optional operation).protected voidremoveRange(int fromIndex, int toIndex)Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.java.lang.StringtoString()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
-
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
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- FIXMEmaxSize- 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
Appends the specified element to the end of this list. -
add
Inserts the specified element at the specified position in this list. -
addAll
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. -
addAll
Inserts all of the elements in the specified Collection into this list, starting at the specified position. -
clone
public java.lang.Object clone()Returns a shallow copy of this BoundedList instance- Overrides:
clonein classjava.util.ArrayList<E>
-
remove
Removes the element at the specified position in this list. -
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:
removeRangein classjava.util.ArrayList<E>- Parameters:
fromIndex- index of first element to be removedtoIndex- 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). -
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). -
toString
public java.lang.String toString()- Overrides:
toStringin classjava.util.AbstractCollection<E>
-