Class FixedSizeList
- All Implemented Interfaces:
Iterable<Object>
,Collection<Object>
,List<Object>
,SequencedCollection<Object>
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 int
Number of elements added in thevalues
array.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 TypeMethodDescriptionboolean
Adds the given value if we have not yet reached the maximal capacity of this list.void
clear()
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.int
size()
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, subList
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, 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 thevalues
array.
-
-
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:
size
in interfaceCollection<Object>
- Specified by:
size
in interfaceList<Object>
- Specified by:
size
in classAbstractCollection<Object>
-
clear
public void clear()Resets the list size to zero, but do not reset the references tonull
.- Specified by:
clear
in interfaceCollection<Object>
- Specified by:
clear
in interfaceList<Object>
- Overrides:
clear
in 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:
add
in interfaceCollection<Object>
- Specified by:
add
in interfaceList<Object>
- Overrides:
add
in classAbstractList<Object>
-