Created by hug on 2/4/2017. Methods are provided in the suggested order that they should be completed.
| 7 | * that they should be completed. |
| 8 | */ |
| 9 | public interface Deque<T> { |
| 10 | |
| 11 | /** |
| 12 | * Add {@code x} to the front of the deque. Assumes {@code x} is never null. |
| 13 | * |
| 14 | * @param x item to add |
| 15 | */ |
| 16 | void addFirst(T x); |
| 17 | |
| 18 | /** |
| 19 | * Add {@code x} to the back of the deque. Assumes {@code x} is never null. |
| 20 | * |
| 21 | * @param x item to add |
| 22 | */ |
| 23 | void addLast(T x); |
| 24 | |
| 25 | /** |
| 26 | * Returns a List copy of the deque. Does not alter tne deque. |
| 27 | * |
| 28 | * @return a new list copy of the deque. |
| 29 | */ |
| 30 | List<T> toList(); |
| 31 | |
| 32 | /** |
| 33 | * Returns if the deque is empty. Does not alter the deque. |
| 34 | * |
| 35 | * @return {@code true} if the deque has no elements, {@code false} otherwise. |
| 36 | */ |
| 37 | boolean isEmpty(); |
| 38 | |
| 39 | /** |
| 40 | * Returns the size of the deque. Does not alter the deque. |
| 41 | * |
| 42 | * @return the number of items in the deque. |
| 43 | */ |
| 44 | int size(); |
| 45 | |
| 46 | /** |
| 47 | * Remove and return the element at the front of the deque, if it exists. |
| 48 | * |
| 49 | * @return removed element, otherwise {@code null}. |
| 50 | */ |
| 51 | T removeFirst(); |
| 52 | |
| 53 | /** |
| 54 | * Remove and return the element at the back of the deque, if it exists. |
| 55 | * |
| 56 | * @return removed element, otherwise {@code null}. |
| 57 | */ |
| 58 | T removeLast(); |
| 59 | |
| 60 | /** |
| 61 | * The Deque abstract data type does not typically have a get method, |
| 62 | * but we've included this extra operation to provide you with some |
| 63 | * extra programming practice. Gets the element, iteratively.Does |
| 64 | * not alter the deque. |
| 65 | * |
| 66 | * @param index index to get, assumes valid index |
no outgoing calls
no test coverage detected