MCPcopy Index your code
hub / github.com/Seogeurim/CS-study / LinkedStack

Class LinkedStack

contents/data-structure/code/Stack/LinkedStack.java:5–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import LinkedList.SinglyLinkedList;
4
5public class LinkedStack<E> implements IStack<E> {
6 private SinglyLinkedList<E> list = new SinglyLinkedList<>();
7
8 public LinkedStack() {}
9
10 @Override
11 public int size() {
12 return list.size();
13 }
14
15 @Override
16 public boolean isEmpty() {
17 return list.isEmpty();
18 }
19
20 @Override
21 public void push(E e) {
22 list.addFirst(e);
23 }
24
25 @Override
26 public E pop() {
27 return list.removeFirst();
28 }
29
30 @Override
31 public E peek() {
32 return list.first();
33 }
34}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected