Skip to content

Commit

Permalink
Empty fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jpolitz committed Jan 21, 2018
1 parent be4d654 commit ff36749
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions ucsd-cse12-pa2-student/src/cse12pa2student/CSE12DLList.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ public class CSE12DLList<E> implements CSE12List<E> {

private Node<E> head, tail;
private int size;

public CSE12DLList() {
this.head = new Node<E>(null, null, null);
this.tail = new Node<E>(null, null, this.head);
this.head.succ = tail;
this.tail.prev = head;
}

@Override
public void append(E e) {
this.size += 1;
Expand All @@ -30,8 +30,8 @@ public void prepend(E e) {

@Override
public void empty() {
this.head = new Node<E>(null, null, null);
this.tail = this.head;
this.head.succ = tail;
this.tail.prev = head;
this.size = 0;
}

Expand All @@ -42,11 +42,11 @@ public int size() {

@Override
public E getAt(int index) {
if(index >= this.size || index < 0) {
if (index >= this.size || index < 0) {
throw new IndexOutOfBoundsException("Index " + index + " out of bounds.");
}
Node<E> curr = head.succ;
while(index > 0 && curr.value != null) {
while (index > 0 && curr.value != null) {
curr = curr.succ;
index -= 1;
}
Expand All @@ -69,6 +69,5 @@ public int findFirst(E e) {
/** TODO **/
return -1;
}


}

0 comments on commit ff36749

Please sign in to comment.