|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.umd.cloud9.util.array.ArrayListOfInts
public class ArrayListOfInts
Object representing a list of ints, backed by an resizable-array.
| Constructor Summary | |
|---|---|
ArrayListOfInts()
Constructs an empty list with an initial capacity of ten. |
|
ArrayListOfInts(int initialCapacity)
Constructs an empty list with the specified initial capacity. |
|
ArrayListOfInts(int[] a)
|
|
| Method Summary | |
|---|---|
void |
add(int e)
Appends the specified element to the end of this list. |
void |
add(int index,
int element)
Inserts the specified element at the specified position in this list. |
void |
clear()
Removes all of the elements from this list. |
ArrayListOfInts |
clone()
Returns a clone of this object. |
boolean |
contains(int n)
Returns true if this list contains the specified element. |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this object, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument. |
int |
get(int index)
Returns the element at the specified position in this list. |
int[] |
getArray()
Returns the array backing this object. |
int |
indexOf(int n)
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. |
boolean |
isEmpty()
Returns true if this list contains no elements. |
Iterator<Integer> |
iterator()
Returns an iterator for this list. |
int |
lastIndexOf(int n)
Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. |
int |
remove(int index)
Removes the element at the specified position in this list. |
int |
set(int index,
int element)
Replaces the element at the specified position in this list with the specified element. |
void |
setSize(int sz)
Specifies the length of this list. |
void |
shiftLastNToTop(int n)
|
int |
size()
Returns the number of elements in this list. |
String |
toString()
|
String |
toString(int n)
Returns a string representation of the object, explicitly printing out the first n elements of this list. |
void |
trimToSize()
Trims the capacity of this object to be the list's current size. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ArrayListOfInts(int initialCapacity)
initialCapacity - the initial capacity of the list
IllegalArgumentException - if the specified initial capacity is negativepublic ArrayListOfInts()
public ArrayListOfInts(int[] a)
| Method Detail |
|---|
public void trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity - the desired minimum capacitypublic int size()
public void setSize(int sz)
public boolean isEmpty()
public boolean contains(int n)
n - element whose presence in this list is to be tested
public int indexOf(int n)
public int lastIndexOf(int n)
public ArrayListOfInts clone()
clone in class Objectpublic int get(int index)
index - index of the element to return
public int set(int index,
int element)
index - index of the element to replaceelement - element to be stored at the specified position
public void add(int e)
e - element to be appended to this list
public void add(int index,
int element)
index - index at which the specified element is to be insertedelement - element to be insertedpublic int remove(int index)
index - the index of the element to be removed
public void clear()
public int[] getArray()
public void shiftLastNToTop(int n)
public Iterator<Integer> iterator()
Iterable interface; this
method is not efficient because of autoboxing.
iterator in interface Iterable<Integer>public String toString(int n)
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||