|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectzombie.util.AbstractIntCollection
zombie.util.list.AbstractIntList
zombie.util.list.IntArrayList
public class IntArrayList
This class represents an array implemenation of lists of int values.
ArrayList,
Serialized Form| Field Summary | |
|---|---|
static int |
DEFAULT_CAPACITY
The default capacity of this list. |
static int |
DEFAULT_GROWTH_CHUNK
The default chunk size with which to increase the capacity of this list. |
static double |
DEFAULT_GROWTH_FACTOR
The default factor with which to increase the capacity of this list. |
| Constructor Summary | |
|---|---|
IntArrayList()
Creates a new array list with capacity 10 and a relative growth factor of 1.0. |
|
IntArrayList(int capacity)
Creates a new array list with a specified capacity and a relative growth factor of 1.0. |
|
IntArrayList(int[] a)
Creates a new array list with the same elements as a specified array. |
|
IntArrayList(IntCollection c)
Creates a new array list with the same elements as a specified collection. |
|
IntArrayList(int capacity,
double growthFactor)
Creates a new array list with a specified capacity and relative growth factor. |
|
IntArrayList(int capacity,
int growthChunk)
Creates a new array list with a specified capacity and absolute growth factor. |
|
| Method Summary | |
|---|---|
void |
add(int index,
int v)
Throws UnsupportedOperationException. |
int |
capacity()
Returns the current capacity of this list. |
void |
clear()
Clears this collection. |
java.lang.Object |
clone()
Returns a clone of this array list. |
boolean |
contains(int v)
Indicates whether this collection contains a specified element. |
int |
ensureCapacity(int capacity)
Ensures that this list has at least a specified capacity. |
boolean |
equals(java.lang.Object obj)
Indicates whether this collection is equal to some object. |
int |
get(int index)
Returns the element at a specified position in this list. |
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. |
boolean |
isEmpty()
Indicates whether this collection is empty. |
int |
lastIndexOf(int c)
Returns the index of the last occurance of a specified element in this list. |
boolean |
remove(int v)
Removes a specified element from this collection. |
int |
removeElementAt(int index)
Throws UnsupportedOperationException. |
int |
set(int index,
int v)
Sets a specified element to a new value. |
int |
size()
Returns the number of elements in this collection. |
int[] |
toArray()
Returns the elements of this collection as an array. |
int[] |
toArray(int[] a)
Returns the elements of this collection as an array. |
void |
trimToSize()
Minimizes the memory used by this array list. |
| Methods inherited from class zombie.util.list.AbstractIntList |
|---|
add, addAll, iterator, lastIndexOf, listIterator, listIterator |
| Methods inherited from class zombie.util.AbstractIntCollection |
|---|
addAll, containsAll, removeAll, retainAll, toString |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface zombie.util.IntCollection |
|---|
addAll, containsAll, removeAll, retainAll |
| Field Detail |
|---|
public static final double DEFAULT_GROWTH_FACTOR
public static final int DEFAULT_GROWTH_CHUNK
public static final int DEFAULT_CAPACITY
| Constructor Detail |
|---|
public IntArrayList()
IntArrayList(int,double)public IntArrayList(IntCollection c)
c - the collection whose elements to add to the new
list.
java.lang.NullPointerException - if c is null.public IntArrayList(int[] a)
a - the array whose elements to add to the new
list.
java.lang.NullPointerException - if a is null.public IntArrayList(int capacity)
capacity - the initial capacity of the list.
java.lang.IllegalArgumentException - if capacity is negative.IntArrayList(int,double)
public IntArrayList(int capacity,
double growthFactor)
The array capacity increases to capacity()*(1+growthFactor). This strategy is good for avoiding many capacity increases, but the amount of wasted memory is approximately the size of the list.
capacity - the initial capacity of the list.growthFactor - the relative amount with which to increase the
the capacity when a capacity increase is needed.
java.lang.IllegalArgumentException - if capacity is negative;
if growthFactor is negative.
public IntArrayList(int capacity,
int growthChunk)
The array capacity increases to capacity()+growthChunk. This strategy is good for avoiding wasting memory. However, an overhead is potentially introduced by frequent capacity increases.
capacity - the initial capacity of the list.growthChunk - the absolute amount with which to increase the
the capacity when a capacity increase is needed.
java.lang.IllegalArgumentException - if capacity is negative;
if growthChunk is negative.| Method Detail |
|---|
public int ensureCapacity(int capacity)
capacity - the minimum capacity of this list.
capacity()public int capacity()
ensureCapacity(int)
public void add(int index,
int v)
AbstractIntList
add in interface IntListadd in class AbstractIntListindex - 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.IntCollection.add(int),
IntCollection.addAll(IntCollection),
IntList.addAll(int,IntCollection)public int get(int index)
IntList
get in interface IntListindex - the position of the element to return.
public int set(int index,
int v)
IntList
set in interface IntListindex - the index of the element whose value to set.v - the new value of the specified element.
public int removeElementAt(int index)
AbstractIntList
removeElementAt in interface IntListremoveElementAt in class AbstractIntListindex - the index of the element to remove.
public void trimToSize()
trimToSize in interface IntCollectiontrimToSize in class AbstractIntCollectionpublic java.lang.Object clone()
clone in class java.lang.Objectpublic int size()
IntCollection
size in interface IntCollectionsize in class AbstractIntCollectionpublic boolean isEmpty()
IntCollection
isEmpty in interface IntCollectionisEmpty in class AbstractIntCollectionpublic void clear()
IntCollection
clear in interface IntCollectionclear in class AbstractIntCollectionpublic boolean contains(int v)
IntCollection
contains in interface IntCollectioncontains in class AbstractIntCollectionv - the element to test for containment.
IntCollection.containsAll(IntCollection)public int indexOf(int c)
IntList
indexOf in interface IntListindexOf in class AbstractIntListc - the element to find.
public int indexOf(int index,
int c)
IntList
indexOf in interface IntListindexOf in class AbstractIntListindex - the index at which to start the search.c - the element to find.
public int lastIndexOf(int c)
IntList
lastIndexOf in interface IntListlastIndexOf in class AbstractIntListc - the element to find.
public boolean remove(int v)
IntCollection
remove in interface IntCollectionremove in class AbstractIntCollectionv - the int value to remove from this collection.
public int[] toArray()
IntCollection
toArray in interface IntCollectiontoArray in class AbstractIntCollectionpublic int[] toArray(int[] a)
IntCollection
toArray in interface IntCollectiontoArray in class AbstractIntCollectiona - an array to fill with the elements of this
collection; if a is null or not
big enough to contain all the elements of this
collection, an new array is allocated,
and a is not changed.
public boolean equals(java.lang.Object obj)
IntCollection
equals in interface IntCollectionequals in class AbstractIntListobj - the object with which to compare this collection.
public int hashCode()
IntCollection
hashCode in interface IntCollectionhashCode in class AbstractIntList
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||