Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Queuee
- {
- class Queue
- {
- Node front = null;
- Node rear = null;
- public void push(int val)
- {
- Node tmp = new Node(val);
- if (front == null && rear == null)
- {
- front = tmp;
- rear = tmp;
- return;
- }
- rear.next = tmp;
- rear = tmp;
- }
- public int top()
- {
- if (front == null)
- {
- return 0;
- }
- return front.info;
- }
- public void pop()
- {
- if (front == null)
- {
- return;
- }
- front = front.next;
- }
- public bool empty()
- {
- return (front == null);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement