Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Add pop function to queue.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rickey90 committed May 23, 2019
1 parent 555c651 commit b62c23f
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<details>
<summary>View contents</summary>
<ol>
<li><a href="#pop-queue"><code>pop</code></a></li>
<li><a href="#pop"><code>pop</code></a></li>
<li><a href="#back-queue"><code>back</code></a></li>
<li><a href="#push"><code>push</code></a></li>
<li><a href="#size-queue"><code>size</code></a></li>
Expand All @@ -16,6 +16,30 @@
</ol>
</details>

# 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<int> 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.
Expand Down

0 comments on commit b62c23f

Please sign in to comment.