Package org.olap4j.impl
Class UnmodifiableArrayList<T>
java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractList<T>
org.olap4j.impl.UnmodifiableArrayList<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,List<T>,SequencedCollection<T>
Unmodifiable list backed by an array.
The traditional solution to this problem is to call
Arrays.asList(Object[]) followed by
Collections.unmodifiableList(java.util.List), but this
class has one fewer wrapper object, saving space and indirection effort.
- Since:
- May 7, 2009
- Author:
- jhyde
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> UnmodifiableArrayList<T> asCopyOf(T... elements) Creates an unmodifable list as a shallow copy of an array.get(int index) static <T> UnmodifiableArrayList<T> of(Collection<? extends T> collection) Creates an unmodifable list as a shallow copy of a collection.intsize()Methods inherited from class java.util.AbstractList
add, add, addAll, clear, 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, stream, toArrayMethods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, equals, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, set, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
UnmodifiableArrayList
Creates an UnmodifiableArrayList.Does not create a copy of the array. Future changes to the array will be reflected in the contents of the list.
- Parameters:
elements- Array
-
-
Method Details
-
get
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceList<T>- Specified by:
sizein classAbstractCollection<T>
-
asCopyOf
Creates an unmodifable list as a shallow copy of an array.Future changes to the array will not be reflected in the contents of the list.
- Type Parameters:
T- Type of elements- Parameters:
elements- Elements of list- Returns:
- Unmodifiable list with same contents that the array had at call time
-
of
Creates an unmodifable list as a shallow copy of a collection.Future changes to the collection will not be reflected in the contents of the list.
- Type Parameters:
T- Type of elements- Parameters:
collection- Elements of list- Returns:
- Unmodifiable list with same contents that the collection had at call time
-