2015-03-25 MyDeque

posted Mar 24, 2015, 6:45 PM by Samuel Konstantinovich   [ updated Mar 24, 2015, 8:21 PM ]
Goal: Double Ended Queue : Deque ...

http://docs.oracle.com/javase/7/docs/api/java/util/Deque.html (pronounced Deck)
You will write MyDeque.java in your github folder 10. I expect several commits per coding session to track your changes over time. I expect you to have several commits in class as you build this data structure. 

There are 6 public methods:
1. void addFirst(T value)
2. void addLast(T value)
-When the array is full, resize, then add. 
-No exceptions are required since you will resize.

3. T removeFirst()  *warning*
4. T removeLast()  *warning*
-NoSuchElementException is thrown when there are no elements. 

5. T getFirst()  *warning*
6. T getLast()  *warning*
-NoSuchElementException is thrown when there are no elements. 

7. You need a method to resize and copy over the values to .

*You will get 4 warnings when you typecast to (T) from object. You should have no other warnings. (compile with -Xlint:unchecked to see the warnings)
MyDeque.java:37: warning: [unchecked] unchecked cast
T value = (T)data[tail];
  required: T
  found:    Object
  where T is a type-variable:
    T extends Object declared in class MyDeque