-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListADT.java
59 lines (42 loc) · 1.83 KB
/
ListADT.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
/* Joshua Villasenor
masc0431
*/
package data_structures;
import java.util.Iterator;
public interface ListADT<E> extends Iterable<E> {
// Adds the Object obj to the beginning of the list
public void addFirst(E obj);
// Adds the Object obj to the end of the list
public void addLast(E o);
// Removes the first Object in the list and returns it.
// Returns null if the list is empty.
public E removeFirst();
// Removes the last Object in the list and returns it.
// Returns null if the list is empty.
public E removeLast();
// Returns the first Object in the list, but does not remove it.
// Returns null if the list is empty.
public E peekFirst();
// Returns the last Object in the list, but does not remove it.
// Returns null if the list is empty.
public E peekLast();
// Finds and returns the Object obj if it is in the list, otherwise
// returns null. Does not modify the list in any way
public E find(E obj);
// Removes the first instance of thespecific Object obj from the list, if it exists.
// Returns true if the Object obj was found and removed, otherwise false
public boolean remove(E obj);
// The list is returned to an empty state.
public void makeEmpty();
// Returns true if the list contains the Object obj, otherwise false
public boolean contains(E obj);
// Returns true if the list is empty, otherwise false
public boolean isEmpty();
// Returns true if the list is full, otherwise false
public boolean isFull();
// Returns the number of Objects currently in the list.
public int size();
// Returns an Iterator of the values in the list, presented in
// the same order as the list.
public Iterator<E> iterator();
}