Class FixedSizeList
Wraps an array of fixed size. Attempts to add a new element fail when the list reached its maximal capacity.
Clearing the array does not set the references to
null, since we need to remember
the values of previous passes. This implementation is designed for compliance with the part of Moving Features
specification saying that "if the value equals the previous value, the text for the value can be omitted".- Since:
- 0.8
- Version:
- 0.8
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intNumber of elements added in thevaluesarray.private final Object[]The array where to store the values.Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionFixedSizeList(Object[] values) Creates a new list wrapping the given array of values. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the given value if we have not yet reached the maximal capacity of this list.voidclear()Resets the list size to zero, but do not reset the references tonull.get(int index) Returns the value at the given index without check of index validity.intsize()Returns the number of elements added in the values array.Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, streamMethods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Field Details
-
values
The array where to store the values. Elements in this array are usually not null even if this list is empty. -
size
private int sizeNumber of elements added in thevaluesarray.
-
-
Constructor Details
-
FixedSizeList
FixedSizeList(Object[] values) Creates a new list wrapping the given array of values.
-
-
Method Details
-
size
public int size()Returns the number of elements added in the values array.- Specified by:
sizein interfaceCollection<Object>- Specified by:
sizein interfaceList<Object>- Specified by:
sizein classAbstractCollection<Object>
-
clear
public void clear()Resets the list size to zero, but do not reset the references tonull.- Specified by:
clearin interfaceCollection<Object>- Specified by:
clearin interfaceList<Object>- Overrides:
clearin classAbstractList<Object>
-
get
Returns the value at the given index without check of index validity. We do not bother verifying that index < size because this list is used only for internal purpose. -
add
Adds the given value if we have not yet reached the maximal capacity of this list.- Specified by:
addin interfaceCollection<Object>- Specified by:
addin interfaceList<Object>- Overrides:
addin classAbstractList<Object>
-