public class IntList extends Object
| Constructor and Description |
|---|
IntList()
Create an empty list with a default capacity.
|
IntList(int capacity)
Create an empty list with the specified capacity.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int n)
Add an entry to the end of the list.
|
void |
clear()
Empty this list
|
void |
fillTo(int toIndex,
int val)
Pad the list with entries.
|
int |
get(int i) |
void |
set(int index,
int n)
Assign an entry in the list.
|
int |
size() |
String |
toString() |
public IntList()
public IntList(int capacity)
capacity - number of entries the list can initially hold.public int size()
public int get(int i)
i - index to read, must be in the range [0, size()).ArrayIndexOutOfBoundsException - the index outside the valid rangepublic void clear()
public void add(int n)
n - the number to add.public void set(int index,
int n)
index - index to set, must be in the range [0, size()).n - value to store at the position.public void fillTo(int toIndex,
int val)
toIndex - index position to stop filling at. 0 inserts no filler. 1
ensures the list has a size of 1, adding val if
the list is currently empty.val - value to insert into padded positions.Copyright © 2013. All rights reserved.