-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathList.java
67 lines (61 loc) · 1.5 KB
/
List.java
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* Interface of List.
*
* @param <E> type of the stored elements
*/
interface List<E> extends Collection<E> {
/**
* Return size of the list.
*
* @return size
*/
int size();
/**
* Check whether the list is empty.
*
* @return empty or not
*/
boolean isEmpty();
/**
* Get i-th element.
*
* @param i index of the element
* @return element at the index
* @throws IndexOutOfBoundsException
* if index is not in the list
*/
E get(int i) throws IndexOutOfBoundsException;
/**
* Set i-th element.
* @param i index of the element
* @param e new value for the element
* @return the inserted element
* @throws IndexOutOfBoundsException
* if index is not in the list
*/
E set(int i, E e) throws IndexOutOfBoundsException;
/**
* Add new element at index i.
*
* @param i index of the element
* @param e element to be added
* @throws IndexOutOfBoundsException
* if index is not in the list
*/
void add(int i, E e) throws IndexOutOfBoundsException;
/**
* Remove the element at index i.
*
* @param i index of element to be removed.
* @return the removed element
* @throws IndexOutOfBoundsException
* if index is not in the list
*/
E remove(int i) throws IndexOutOfBoundsException;
/**
* Returns an iterator over the elements of the list.
*
* @return an iterator
*/
Iterator<E> iterator();
}