Package zombie.util.list
Class AbstractIntList
java.lang.Object
zombie.util.AbstractIntCollection
zombie.util.list.AbstractIntList
- All Implemented Interfaces:
IntCollection
,IntList
- Direct Known Subclasses:
IntArrayList
This class represents an abstract base for implementing
lists of int values. All operations that can be implemented
using iterators and the get() and set() methods
are implemented as such. In most cases, this is
hardly an efficient solution, and at least some of those
methods should be overridden by sub-classes.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(int v) Throws UnsupportedOperationException.void
add
(int index, int v) Throws UnsupportedOperationException.boolean
addAll
(int index, IntCollection c) Adds all the elements of a specified collection to this list starting at a specified index.boolean
Indicates whether this collection is equal to some object.int
hashCode()
Returns a hash code value for this collection.int
indexOf
(int c) Returns the index of the first occurance of a specified element in this list.int
indexOf
(int index, int c) Returns the index of the first occurance of a specified element in this list after or at a specified index.iterator()
Returns an iterator over this collection.int
lastIndexOf
(int c) Returns the index of the last occurance of a specified element in this list.int
lastIndexOf
(int index, int c) Returns the index of the last occurance of a specified element in this list before a specified index.Returns a list iterator over this list.listIterator
(int index) Returns a list iterator over this list, starting from a specified index.int
removeElementAt
(int index) Throws UnsupportedOperationException.Methods inherited from class zombie.util.AbstractIntCollection
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toString, trimToSize
Methods inherited from interface zombie.util.IntCollection
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, trimToSize
-
Method Details
-
add
public boolean add(int v) Description copied from class:AbstractIntCollection
Throws UnsupportedOperationException.- Specified by:
add
in interfaceIntCollection
- Overrides:
add
in classAbstractIntCollection
- Parameters:
v
- the element to add to this collection.- Returns:
- true if this collection was modified as a result of adding v; returns false otherwise.
- See Also:
-
add
public void add(int index, int v) Throws UnsupportedOperationException.- Specified by:
add
in interfaceIntList
- Parameters:
index
- the index at which to add the element. If index == size() the element is appended to this list.v
- the int value to add to this list.- Throws:
UnsupportedOperationException
- unconditionally.- See Also:
-
addAll
Description copied from interface:IntList
Adds all the elements of a specified collection to this list starting at a specified index. The elements are inserted in the specified collection's iteration order. All elements from the specified index and forward are pushed to their successors' indices (c.size() indices).- Specified by:
addAll
in interfaceIntList
- Parameters:
index
- the index at which to insert the elements of the specified collection. If index == size() the elements are appended to this list.c
- the collection whose elements to add to this list.- Returns:
- true if this list was modified as a result of adding the elements of c; returns false otherwise.
- See Also:
-
indexOf
public int indexOf(int c) Description copied from interface:IntList
Returns the index of the first occurance of a specified element in this list. -
indexOf
public int indexOf(int index, int c) Description copied from interface:IntList
Returns the index of the first occurance of a specified element in this list after or at a specified index. -
iterator
Description copied from interface:IntCollection
Returns an iterator over this collection.- Specified by:
iterator
in interfaceIntCollection
- Returns:
- an iterator over this collection.
-
lastIndexOf
public int lastIndexOf(int c) Description copied from interface:IntList
Returns the index of the last occurance of a specified element in this list.- Specified by:
lastIndexOf
in interfaceIntList
- Parameters:
c
- the element to find.- Returns:
- the index of the last occurance of the specified element in this list; returns -1, if the element is not contained in this list.
-
lastIndexOf
public int lastIndexOf(int index, int c) Description copied from interface:IntList
Returns the index of the last occurance of a specified element in this list before a specified index.- Specified by:
lastIndexOf
in interfaceIntList
- Parameters:
index
- the index at which to start the search. Note that the element atindex
is not included in the search.c
- the element to find.- Returns:
- the index of the last occurance of the specified element in this list; returns -1, if the element is not contained in this list.
-
listIterator
Description copied from interface:IntList
Returns a list iterator over this list.- Specified by:
listIterator
in interfaceIntList
- Returns:
- a list iterator over this list.
-
listIterator
Description copied from interface:IntList
Returns a list iterator over this list, starting from a specified index.- Specified by:
listIterator
in interfaceIntList
- Parameters:
index
- the index at which to begin the iteration.- Returns:
- a list iterator over this list.
-
removeElementAt
public int removeElementAt(int index) Throws UnsupportedOperationException.- Specified by:
removeElementAt
in interfaceIntList
- Parameters:
index
- the index of the element to remove.- Returns:
- the value of the element removed.
- Throws:
UnsupportedOperationException
- unconditionally.
-
equals
Description copied from interface:IntCollection
Indicates whether this collection is equal to some object.- Specified by:
equals
in interfaceIntCollection
- Overrides:
equals
in classObject
- Parameters:
obj
- the object with which to compare this collection.- Returns:
- true if this collection is equals to obj; returns false otherwise.
-
hashCode
public int hashCode()Description copied from interface:IntCollection
Returns a hash code value for this collection.- Specified by:
hashCode
in interfaceIntCollection
- Overrides:
hashCode
in classObject
- Returns:
- a hash code value for this collection.
-