Package cern.colt.list.adapter
Class IntListAdapter
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList
-
- cern.colt.list.adapter.IntListAdapter
-
- All Implemented Interfaces:
java.lang.Iterable,java.util.Collection,java.util.List
public class IntListAdapter extends java.util.AbstractList implements java.util.ListAdapter that permits anAbstractIntListto be viewed and treated as a JDK 1.2AbstractList. Makes the contained list compatible with the JDK 1.2 Collections Framework.Any attempt to pass elements other than java.lang.Number to setter methods will throw a java.lang.ClassCastException. java.lang.Number.intValue() is used to convert objects into primitive values which are then stored in the backing templated list. Getter methods return java.lang.Integer objects.
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractIntListcontent
-
Constructor Summary
Constructors Constructor Description IntListAdapter(AbstractIntList content)Constructs a list backed by the specified content list.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, java.lang.Object element)Inserts the specified element at the specified position in this list (optional operation).java.lang.Objectget(int index)Returns the element at the specified position in this list.protected static java.lang.Objectobject(int element)Transforms an element of a primitive data type to an object.java.lang.Objectremove(int index)Removes the element at the specified position in this list (optional operation).java.lang.Objectset(int index, java.lang.Object element)Replaces the element at the specified position in this list with the specified element (optional operation).intsize()Returns the number of elements in this list.protected static intvalue(java.lang.Object element)Transforms an object element to a primitive data type.-
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
-
-
-
-
Field Detail
-
content
protected AbstractIntList content
-
-
Constructor Detail
-
IntListAdapter
public IntListAdapter(AbstractIntList content)
Constructs a list backed by the specified content list.
-
-
Method Detail
-
add
public void add(int index, java.lang.Object element)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:
addin interfacejava.util.List- Overrides:
addin classjava.util.AbstractList- Parameters:
index- index at which the specified element is to be inserted.element- element to be inserted.- Throws:
java.lang.ClassCastException- if the class of the specified element prevents it from being added to this list.java.lang.IllegalArgumentException- if some aspect of the specified element prevents it from being added to this list.java.lang.IndexOutOfBoundsException- index is out of range (index < 0 || index > size()).
-
get
public java.lang.Object get(int index)
Returns the element at the specified position in this list.- Specified by:
getin interfacejava.util.List- Specified by:
getin classjava.util.AbstractList- Parameters:
index- index of element to return.- Returns:
- the element at the specified position in this list.
- Throws:
java.lang.IndexOutOfBoundsException- if the given index is out of range (index < 0 || index >= size()).
-
object
protected static java.lang.Object object(int element)
Transforms an element of a primitive data type to an object.
-
remove
public java.lang.Object remove(int index)
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:
removein interfacejava.util.List- Overrides:
removein classjava.util.AbstractList- Parameters:
index- the index of the element to remove.- Returns:
- the element previously at the specified position.
- Throws:
java.lang.IndexOutOfBoundsException- if the specified index is out of range (index < 0 || index >= size()).
-
set
public java.lang.Object set(int index, java.lang.Object element)Replaces the element at the specified position in this list with the specified element (optional operation).- Specified by:
setin interfacejava.util.List- Overrides:
setin classjava.util.AbstractList- 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:
java.lang.ClassCastException- if the class of the specified element prevents it from being added to this list.java.lang.IllegalArgumentException- if some aspect of the specified element prevents it from being added to this list.java.lang.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:
sizein interfacejava.util.Collection- Specified by:
sizein interfacejava.util.List- Specified by:
sizein classjava.util.AbstractCollection- Returns:
- the number of elements in this list.
-
value
protected static int value(java.lang.Object element)
Transforms an object element to a primitive data type.
-
-