public abstract class AbstractIntList extends AbstractIntCollection implements IntList
int elements.
This class implements Collection allowing
seamless integration with other APIs.
The get(int) and size() methods must be
implemented by subclases.
To make the subclass modifiable, the add(int, int),
removeIndex(int) and set(int, int) must also be implemented.
Subclasses may override other methods to increase efficiency.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractIntList.PListIterator
List iterator.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractIntList()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int value)
Adds a primitive value to this collection (optional operation).
|
boolean |
add(java.lang.Integer value)
Adds the
Integer value to this collection (optional operation). |
boolean |
add(int index,
int value)
Adds a primitive value to this list at an index (optional operation).
|
void |
add(int index,
java.lang.Integer value)
Adds the
Integer value to this list at an index (optional operation). |
boolean |
addAll(int[] values)
Adds an array of primitive values to this list at an index (optional operation).
|
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Integer> coll)
Adds an array of
Integer values to this list at an index (optional operation). |
boolean |
addAll(int index,
int[] values)
Adds an array of primitive values to this list at an index (optional operation).
|
protected void |
arrayCopy(int fromIndex,
int[] dest,
int destIndex,
int size)
Copies data from this collection into the specified array.
|
protected void |
checkIndex(int index)
Checks whether an index is valid or not.
|
protected void |
checkIndexExists(int index)
Checks whether an index is valid or not.
|
protected void |
checkRange(int fromIndexInclusive,
int toIndexExclusive)
Checks whether a range is valid or not.
|
protected void |
checkSetModifiable()
Check whether add is suported and throw an exception.
|
void |
clear()
Clears the listof all elements (optional operation).
|
boolean |
contains(int value)
Checks whether this collection contains a specified primitive value.
|
boolean |
equals(java.lang.Object obj)
Compares this list to another as per the contract of
List. |
java.lang.Integer |
first()
Gets the first
Integer value. |
int |
firstInt()
Gets the first primitive value.
|
java.lang.Integer |
get(int index)
Gets the
Integer value at the specified index. |
int |
hashCode()
Gets the hashCode of this list as per the contract of
List. |
int |
indexOf(int value)
Gets the first index of the specified primitive value.
|
int |
indexOf(int value,
int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.
|
int |
indexOf(java.lang.Object value)
Gets the first index of the specified
Integer value. |
int |
indexOf(java.lang.Object value,
int fromIndexInclusive)
Gets the first index of the specified
Integer value from an index. |
boolean |
isModifiable()
Is the collection modifiable in any way.
|
protected boolean |
isSetModifiable()
Are the set methods supported.
|
IntListIterator |
iterator()
Gets an iterator over this list.
|
java.lang.Integer |
last()
Gets the last
Integer value. |
int |
lastIndexOf(int value)
Gets the last index of the specified primitive value.
|
int |
lastIndexOf(int value,
int fromIndexInclusive)
Gets the first index of the specified primitive value from an index.
|
int |
lastIndexOf(java.lang.Object value)
Gets the last index of the specified
Integer value. |
int |
lastIndexOf(java.lang.Object value,
int fromIndexInclusive)
Gets the first index of the specified
Integer value from an index. |
int |
lastInt()
Gets the last primitive value.
|
IntListIterator |
listIterator()
Gets a list iterator over this list.
|
IntListIterator |
listIterator(int index)
Gets a list iterator over this list from a start index.
|
java.lang.Integer |
remove(int index)
Deprecated.
This method should only be used when working with List and
not when working with IntList - use
removeIntAt(int) |
boolean |
removeInt(int value)
Removes the first occurrence of a primitive value from the list (optional operation).
|
int |
removeIntAt(int index)
Removes a primitive value by index from the list (optional operation).
|
boolean |
removeRange(int fromIndexInclusive,
int toIndexExclusive)
Removes a range of values from the list (optional operation).
|
int |
set(int index,
int value)
Sets the primitive value at a specified index.
|
java.lang.Integer |
set(int index,
java.lang.Integer value)
Sets the
Integer value at a specified index. |
IntList |
subList(int fromIndexInclusive,
int toIndexExclusive)
Deprecated.
Not implemented yet.
|
int[] |
toIntArray(int fromIndexInclusive,
int toIndexExclusive)
Gets a range of elements as an array.
|
addAll, addAll, addAll, checkAddModifiable, checkRemoveModifiable, contains, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, isAddModifiable, isRemoveModifiable, isToPrimitivePossible, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, retainAll, toArray, toArray, toIntArray, toIntArray, toObject, toPrimitive, toPrimitiveArray, toStringclone, isEmpty, optimizefinalize, getClass, notify, notifyAll, wait, wait, waitaddAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, size, sort, spliterator, toArray, toArrayaddAll, addAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, removeAll, removeAll, removeAll, removeAll, removeFirst, retainAll, retainAll, retainAll, toIntArray, toIntArraycontainsAnyclone, isEmpty, optimize, sizepublic IntListIterator iterator()
iterator in interface java.lang.Iterable<java.lang.Integer>iterator in interface java.util.Collection<java.lang.Integer>iterator in interface java.util.List<java.lang.Integer>iterator in interface IntCollectioniterator in interface IntIterableiterator in interface IntListpublic IntListIterator listIterator()
This implementation uses intListIterator(int).
listIterator in interface java.util.List<java.lang.Integer>listIterator in interface IntListpublic IntListIterator listIterator(int index)
listIterator in interface java.util.List<java.lang.Integer>listIterator in interface IntListindex - the index to start fromjava.lang.IndexOutOfBoundsException - if the index is invalidpublic int firstInt()
public int lastInt()
public boolean contains(int value)
This implementation uses getInt(int).
contains in interface IntCollectioncontains in class AbstractIntCollectionvalue - the value to search fortrue if the value is foundpublic int indexOf(int value)
This implementation uses indexof(int, int).
public int indexOf(int value,
int fromIndexInclusive)
This method follows the conventions of String in that a
negative index is treated as zero, and an index greater than the list
size will simply return -1.
This implementation uses get(int).
public int lastIndexOf(int value)
This implementation uses lastIndexof(int, int).
lastIndexOf in interface IntListvalue - the value to search for-1 if not foundpublic int lastIndexOf(int value,
int fromIndexInclusive)
This method follows the conventions of String in that an
index greater than the list size will start searching at the list size,
and a negative index simply returns -1.
This implementation uses get(int).
lastIndexOf in interface IntListvalue - the value to search forfromIndexInclusive - the index to start searching from, inclusive-1 if not foundpublic int[] toIntArray(int fromIndexInclusive,
int toIndexExclusive)
toIntArray in interface IntListfromIndexInclusive - the index to start from, inclusivetoIndexExclusive - the index to end at, exclusivejava.lang.IndexOutOfBoundsException - if either index is invalid@Deprecated public IntList subList(int fromIndexInclusive, int toIndexExclusive)
This method allows operations to work on a range within the greater list. Changes made to the either object will affect the other.
subList in interface java.util.List<java.lang.Integer>subList in interface IntListfromIndexInclusive - the index to start from, inclusivetoIndexExclusive - the index to end at, exclusivejava.lang.UnsupportedOperationException - alwayspublic void clear()
This implementation uses removeRange(int, int).
clear in interface java.util.Collection<java.lang.Integer>clear in interface java.util.List<java.lang.Integer>clear in interface PrimitiveCollectable<java.lang.Integer>clear in class AbstractIntCollectionjava.lang.UnsupportedOperationException - if method not supported by this collectionpublic boolean add(int value)
This implementation uses add(int, int).
add in interface IntCollectionadd in class AbstractIntCollectionvalue - the value to add to this collectiontrue if this collection was modified by this method calljava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean add(int index,
int value)
This implementation throws UnsupportedOperationException.
add in interface IntListindex - the index to add atvalue - the value to add to this collectiontrue if this list was modified by this method calljava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean addAll(int[] values)
This implementation uses addAll(int, int).
addAll in interface IntCollectionaddAll in class AbstractIntCollectionvalues - the values to add to this collection, null treated as empty arraytrue if this list was modified by this method calljava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean addAll(int index,
int[] values)
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
addAll in interface IntListindex - the index to add atvalues - the values to add to this collection, null treated as empty arraytrue if this list was modified by this method calljava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic int removeIntAt(int index)
This implementation throws UnsupportedOperationException.
removeIntAt in interface IntListindex - the index to remove fromjava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean removeInt(int value)
This implementation uses get(int) and removeIntAt(int).
value - the value to removejava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean removeRange(int fromIndexInclusive,
int toIndexExclusive)
This implementation uses removeIntAt(int).
removeRange in interface PrimitiveList<java.lang.Integer>fromIndexInclusive - the start of the range to remove, inclusivetoIndexExclusive - the end of the range to remove, exclusivetrue if the collection was modifiedjava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.UnsupportedOperationException - if remove is not supportedpublic int set(int index,
int value)
This implementation throws UnsupportedOperationException.
set in interface IntListindex - the index to setvalue - the value to storejava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic java.lang.Integer get(int index)
Integer value at the specified index.get in interface java.util.List<java.lang.Integer>index - the index to get fromjava.lang.IndexOutOfBoundsException - if the index is invalidpublic java.lang.Integer first()
Integer value.first in interface PrimitiveList<java.lang.Integer>public java.lang.Integer last()
Integer value.last in interface PrimitiveList<java.lang.Integer>size() - 1 or null if the size is zeropublic int indexOf(java.lang.Object value)
Integer value.indexOf in interface java.util.List<java.lang.Integer>value - the value to search for-1 if not foundjava.lang.NullPointerException - if the value if nulljava.lang.ClassCastException - if the object is not Integerpublic int indexOf(java.lang.Object value,
int fromIndexInclusive)
Integer value from an index.
This method follows the conventions of String in that a
negative index is treated as zero, and an index greater than the list
size will simply return -1.
value - the value to search forfromIndexInclusive - the index to start searching from, inclusive-1 if not foundjava.lang.NullPointerException - if the value if nulljava.lang.ClassCastException - if the object is not Integerpublic int lastIndexOf(java.lang.Object value)
Integer value.lastIndexOf in interface java.util.List<java.lang.Integer>value - the value to search for-1 if not foundjava.lang.NullPointerException - if the value if nulljava.lang.ClassCastException - if the object is not Integerpublic int lastIndexOf(java.lang.Object value,
int fromIndexInclusive)
Integer value from an index.
This method follows the conventions of String in that an
index greater than the list size will start searching at the list size,
and a negative index simply returns -1.
value - the value to search forfromIndexInclusive - the index to start searching from, inclusive-1 if not foundjava.lang.NullPointerException - if the value if nulljava.lang.ClassCastException - if the object is not Integerpublic boolean add(java.lang.Integer value)
Integer value to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
add in interface java.util.Collection<java.lang.Integer>add in interface java.util.List<java.lang.Integer>add in class AbstractIntCollectionvalue - the value to add to this collectiontrue if this collection was modified by this method calljava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic void add(int index,
java.lang.Integer value)
Integer value to this list at an index (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
add in interface java.util.List<java.lang.Integer>index - the index to add atvalue - the value to add to this collectionjava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.ClassCastException - if the object is not Integerjava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean addAll(int index,
java.util.Collection<? extends java.lang.Integer> coll)
Integer values to this list at an index (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
addAll in interface java.util.List<java.lang.Integer>index - the index to add atcoll - the values to add to this collectiontrue if this list was modified by this method calljava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.ClassCastException - if any object is not Integerjava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collection@Deprecated public java.lang.Integer remove(int index)
removeIntAt(int)
This implementation uses removeIntAt(int).
remove in interface java.util.List<java.lang.Integer>remove in interface IntListindex - the index to remove fromjava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.UnsupportedOperationException - if not supported by this collectionpublic java.lang.Integer set(int index,
java.lang.Integer value)
Integer value at a specified index.
This implementation uses set(int, int).
set in interface java.util.List<java.lang.Integer>index - the index to setvalue - the value to storejava.lang.IndexOutOfBoundsException - if the index is invalidjava.lang.IllegalArgumentException - if value is rejected by this collectionjava.lang.UnsupportedOperationException - if not supported by this collectionpublic boolean equals(java.lang.Object obj)
List.equals in interface java.util.Collection<java.lang.Integer>equals in interface java.util.List<java.lang.Integer>equals in class java.lang.Objectobj - the object to compare totrue if the lists are equalpublic int hashCode()
List.hashCode in interface java.util.Collection<java.lang.Integer>hashCode in interface java.util.List<java.lang.Integer>hashCode in class java.lang.Objectprotected void arrayCopy(int fromIndex,
int[] dest,
int destIndex,
int size)
arrayCopy in class AbstractIntCollectionfromIndex - the index to start fromdest - the destination arraydestIndex - the destination start indexsize - the number of items to copyprotected boolean isSetModifiable()
This implementation returns false.
public boolean isModifiable()
isModifiable in interface PrimitiveCollectable<java.lang.Integer>isModifiable in class AbstractIntCollectionprotected void checkSetModifiable()
protected void checkIndexExists(int index)
index - the index to checkjava.lang.IndexOutOfBoundsException - if either index is invalidprotected void checkIndex(int index)
index - the index to checkjava.lang.IndexOutOfBoundsException - if either index is invalidprotected void checkRange(int fromIndexInclusive,
int toIndexExclusive)
fromIndexInclusive - the index to start from, inclusivetoIndexExclusive - the index to end at, exclusivejava.lang.IndexOutOfBoundsException - if either index is invalidCopyright © 2005–2018 Joda.org. All rights reserved.