|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Object
List
public class List
The List class implements a growable array of objects. It contains elements that can be accessed using an integer index. The size of a List can grow or shrink as needed to accommodate adding and removing items after the List has been created.
A List is meant to contain instances of objects found in this api.
Primitives, Strings, binary data and constructs of these
are to be stored in Value structures.
Value| Constructor Summary | |
|---|---|
List()
Constructs a new List instance with initial capacity of 10 elements. |
|
| Method Summary | |
|---|---|
List |
add(int index,
Object element)
Inserts the specified element at the specified position in this list. |
List |
add(Object element)
Appends the specified element to the end of this list |
void |
clear()
Removes all of the elements from this list. |
int |
indexOf(Object obj)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. |
int |
lastIndexOf(Object obj)
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. |
Object |
operator_get(int index)
An operator that returns the element at the specified position in this list. |
Object |
operator_set(int index,
Object element)
Replaces the element at the specified position in this list with the specified element. |
Object |
pop()
Removes the object at the end of of this list and returns that object as the value of this function. |
void |
push(Object element)
Pushes an item onto the end of this list. |
Object |
remove(int index)
Removes the element at the specified position in this list. |
int |
size()
Returns the number of elements in this list. |
void |
sort(Comparator comparator)
Sorts this list according to the order induced by the specified comparator. |
| Methods inherited from class Object |
|---|
toString, equals, hashCode |
| Methods inherited from |
|---|
equals, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public List()
| Method Detail |
|---|
public int size()
public void clear()
public List add(int index,
Object element)
index - index at which the specified element is to be inserted.element - element to be inserted.
List instancepublic List add(Object element)
element - element to be appended to this list.
List instancepublic Object remove(int index)
index - the index of the element to removed.
public int indexOf(Object obj)
obj - element to search for.
public int lastIndexOf(Object obj)
obj - element to search for.
public Object pop()
public void push(Object element)
add(item)
element - the item to be pushed onto this stack.public Object operator_get(int index)
List list = ...;
Object o = list[i];
index - index of element to return.
public Object operator_set(int index,
Object element)
List list = ...;
list[i] = "hello";
index - index of element to replace.element - element to be stored at the specified position.
public void sort(Comparator comparator)
Sorts this list according to the order induced by the specified comparator.
A Comparator callback
function is given that will determine the ordering of successive elements.
comparator - The comparator to determine the order of the list.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||