-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathList.java
More file actions
71 lines (47 loc) · 1.44 KB
/
Copy pathList.java
File metadata and controls
71 lines (47 loc) · 1.44 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
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
68
69
70
71
/**
* List interface
* @author Wei Zhong Tee
* @since 8 May 2020
*/
public interface List<E> {
/** Remove all contents from the list, so it is once again
empty. */
public void clear();
/** Insert an element at the given location.
* allows you to insert after the tail
* @param item The element to be inserted.
*/
public void insert(int index, E item);
/** Append an element at the end of the list.
* @param item The element to be appended.
*/
public void add(E item);
/**
* Remove the element at the given location.
*/
public void remove(int index);
/**
* Get the element in the position to one step left.
* @return element in the node to the left of the node at the index,
* null if at the head.
*/
public E prev(int index);
/** Get the element in the position one step right.
* @return the element in the node to the right of
* the node at the index, null if at the end.
*/
public E next(int index);
/** @return The number of elements in the list. */
public int length();
/** Turn the contents of the Nodes to a string in order from head to end.
* @return The String representation of the
* elements in the list from head to end.
*/
public String toString();
/** Reverse the content of the list.
* if list is A => B => C it becomes C => B => A
*/
public void reverse();
/** @return The element at given position. */
public E getValue(int index);
}