MCPcopy Create free account
hub / github.com/MolinDeng/Princeton-algs4 / removeFirst

Method removeFirst

LabEnv/02Lab/Deque.java:71–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69
70 // remove and return the item from the front
71 public Item removeFirst() {
72 if (isEmpty()) throw new NoSuchElementException("Deque is empty");
73 Item item = first.item;
74 Node oldFront = first;
75 first = oldFront.next;
76 oldFront.next = null;
77 n--;
78 if (isEmpty()) last = null;
79 else first.prev = null;
80 return item;
81 }
82
83 // remove and return the item from the back
84 public Item removeLast() {

Callers 2

mainMethod · 0.95
mainMethod · 0.95

Calls 1

isEmptyMethod · 0.95

Tested by

no test coverage detected