public class SparseFixedSizeList<V> extends AbstractList<V>
List that is backed by a map because the list could be sparsely populated (This is not
particularly good to use when the list it not sparse).
To make it less confusing, especially since the size is fixed and so certain mutative operations are
not supported. By default, all the positions from "0" to "size - 1" are assumed to have the given default value.
Created by ashwin.jayaprakash.
modCount| Constructor and Description |
|---|
SparseFixedSizeList(int fixedVirtualSize,
V defaultValue) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
V element) |
boolean |
add(V v) |
V |
get(int index) |
V |
remove(int index) |
V |
set(int index,
V element) |
int |
size() |
addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArrayparallelStream, removeIf, streampublic SparseFixedSizeList(int fixedVirtualSize,
V defaultValue)
fixedVirtualSize - This is the fixed size of the list. The list may not actually contain this many items.defaultValue - This is the value returned when there is no actual value set or was "null" at a position
in the list.
The default value itself can be null, in which case it might be hard to distinguish
between a condition where the value was set(int, Object) or
added or was just null/default.public boolean add(V v)
add in interface Collection<V>add in interface List<V>add in class AbstractList<V>v - UnsupportedOperationExceptionpublic void add(int index,
V element)
add in interface List<V>add in class AbstractList<V>index - element - UnsupportedOperationExceptionpublic V remove(int index)
remove in interface List<V>remove in class AbstractList<V>index - UnsupportedOperationExceptionpublic V get(int index)
public int size()
size in interface Collection<V>size in interface List<V>size in class AbstractCollection<V>Copyright © 2018. All rights reserved.