Esempio n. 1
0
 @Override
 public int pop() {
   // TODO Auto-generated method stub
   ListNode temp = head;
   head = head.next;
   return temp.getVal();
 }
Esempio n. 2
0
  @Override
  public void push(int val) {
    // TODO Auto-generated method stub
    ListNode current = new ListNode(val);

    if (head == null) {
      head = current;
    } else {
      ListNode iterNode = head;

      while (iterNode.next != null) {
        iterNode = iterNode.next;
      }

      iterNode.next = current;
    }
  }
Esempio n. 3
0
 @Override
 public int peek() {
   // TODO Auto-generated method stub
   return head.getVal();
 }