-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircularLinkedListInterface.java
More file actions
56 lines (47 loc) · 1.78 KB
/
CircularLinkedListInterface.java
File metadata and controls
56 lines (47 loc) · 1.78 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
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Requirements for CircularLinkedList class
* @param <E> element type of the values in the list to be iterated over
*/
public interface CircularLinkedListInterface<E> {
// should have a single no-parameter constructor
/**
* Retrieves a count of elements being maintained by the list.
*
* @return the size of the list (count of elements)
*/
public int getSize();
/**
* Retrieves the data at the specified position in the list
*
* @param position 0-based index for the list; must be in the range 0 to size - 1
* @return the data in the specified position in the list
*/
public E get(int position);
/**
* Adds a new node to the end of the list; by nature, this element's next will point to the first element
*
* @param value the element to add to the list
*/
public void add(E value);
/**
* Removes the specified item from the list, if it exists there.
*
* @param value the element to remove from the list
* @return true, if the element was found and removed; false, if not found or list is empty
*/
public boolean remove(E value);
/**
* Removes the node at the specified position in the list
* @param position position in the list; must be in range 0 to size - 1
*/
public void remove(int position);
/**
* Retrieves an iterator over the list's elements. Do not do other list operations like add or remove
* from within an iterator loop; the results are not guaranteed to function as you might expect
*
* @return a strongly typed iterator over elements in the list
*/
public Iterator<E> iterator();
}