-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathList.java
More file actions
36 lines (27 loc) · 1.04 KB
/
List.java
File metadata and controls
36 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*****************************************************
* interface List
* Specifies actions a List must be able to perform.
* New in Version 6: Iterability via FOREACH
* (The Iterable interface is a superinterface to interface List,
* in the actual Java library. Interface Iterable is what allows
* a for-each loop to be run on a collection class.)
*****************************************************/
import java.util.Iterator;
public interface List<T> extends Iterable<T>
{
//add element T to end of list
//always return true
public boolean add( T x );
//insert element T at index i
public void add( int i, T newVal );
//remove element at index i
public T remove( int i );
//return element at index i
public T get( int i );
//overwrite element at index i, return old element at index i
public T set( int i, T x );
//return number of meaningful elements in list
public int size();
//return an Iterator over the elements in list
Iterator<T> iterator();
}//end interface List