Package cern.colt.list.adapter
Class ObjectListAdapter
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
cern.colt.list.adapter.ObjectListAdapter
- All Implemented Interfaces:
Iterable
,Collection
,List
,SequencedCollection
Adapter that permits an
ObjectArrayList
to be viewed and treated as a JDK 1.2 AbstractList
.
Makes the contained list compatible with the JDK 1.2 Collections Framework.-
Field Summary
FieldsFields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsConstructorDescriptionObjectListAdapter
(ObjectArrayList content) Constructs a list backed by the specified content list. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Inserts the specified element at the specified position in this list (optional operation).get
(int index) Returns the element at the specified position in this list.remove
(int index) Removes the element at the specified position in this list (optional operation).Replaces the element at the specified position in this list with the specified element (optional operation).int
size()
Returns the number of elements in this list.Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, 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
add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, equals, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, subList, toArray, toArray
-
Field Details
-
-
Constructor Details
-
ObjectListAdapter
Constructs a list backed by the specified content list.
-
-
Method Details
-
add
Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).- Specified by:
add
in interfaceList
- Overrides:
add
in classAbstractList
- Parameters:
index
- index at which the specified element is to be inserted.element
- element to be inserted.- Throws:
ClassCastException
- if the class of the specified element prevents it from being added to this list.IllegalArgumentException
- if some aspect of the specified element prevents it from being added to this list.IndexOutOfBoundsException
- index is out of range (index < 0 || index > size()).
-
get
Returns the element at the specified position in this list.- Specified by:
get
in interfaceList
- Specified by:
get
in classAbstractList
- Parameters:
index
- index of element to return.- Returns:
- the element at the specified position in this list.
- Throws:
IndexOutOfBoundsException
- if the given index is out of range (index < 0 || index >= size()).
-
remove
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.- Specified by:
remove
in interfaceList
- Overrides:
remove
in classAbstractList
- Parameters:
index
- the index of the element to remove.- Returns:
- the element previously at the specified position.
- Throws:
IndexOutOfBoundsException
- if the specified index is out of range (index < 0 || index >= size()).
-
set
Replaces the element at the specified position in this list with the specified element (optional operation).- Specified by:
set
in interfaceList
- Overrides:
set
in classAbstractList
- Parameters:
index
- index of element to replace.element
- element to be stored at the specified position.- Returns:
- the element previously at the specified position.
- Throws:
ClassCastException
- if the class of the specified element prevents it from being added to this list.IllegalArgumentException
- if some aspect of the specified element prevents it from being added to this list.IndexOutOfBoundsException
- if the specified index is out of range (index < 0 || index >= size()).
-
size
public int size()Returns the number of elements in this list.- Specified by:
size
in interfaceCollection
- Specified by:
size
in interfaceList
- Specified by:
size
in classAbstractCollection
- Returns:
- the number of elements in this list.
-