From b62c23ffdb1a3f6596bd806bc1c8e6cd8930a6ee Mon Sep 17 00:00:00 2001 From: Rickey Patel Date: Wed, 22 May 2019 22:39:41 -0500 Subject: [PATCH] Add pop function to queue.md --- queue.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/queue.md b/queue.md index dc9f7cce..fccc71a6 100644 --- a/queue.md +++ b/queue.md @@ -3,7 +3,7 @@
View contents
    -
  1. pop
  2. +
  3. pop
  4. back
  5. push
  6. size
  7. @@ -16,6 +16,30 @@
+# pop +**Description** : pop() function is used to remove an element from the front of the queue (ie. the oldest element in the queue). The element is removed from the queue container and the size of the queue is decreased by 1. + +**Example**: +```cpp + // Empty queue + queue myqueue; + + // pushing elements into queue using push() + myqueue.push(0); + myqueue.push(1); + myqueue.push(2); + + // pop items from queue + myqueue.pop(); // pops 0 from queue + myqueue.pop(); // pops 1 from queue + + // print contents of queue + while (!myqueue.empty()) { + cout << ' ' << myqueue.front(); + myqueue.pop(); + } +``` + # push **Description** : push() function is used to insert an element at the back of the queue. The element is added to the queue container and the size of the queue is increased by 1.