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

Commit

Permalink
Added push to queue.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rickey90 committed May 11, 2019
1 parent 53f8047 commit 555c651
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ol>
<li><a href="#pop-queue"><code>pop</code></a></li>
<li><a href="#back-queue"><code>back</code></a></li>
<li><a href="#push-queue"><code>push</code></a></li>
<li><a href="#push"><code>push</code></a></li>
<li><a href="#size-queue"><code>size</code></a></li>
<li><a href="#swap-queue"><code>swap</code></a></li>
<li><a href="#empty-queue"><code>empty</code></a></li>
Expand All @@ -14,4 +14,24 @@
<li><a href="#queue"><code>queue</code></a></li>
<li><a href="#~queue"><code>~queue</code></a>
</ol>
</details>
</details>

# 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.

**Example**:
```cpp
// Empty queue
queue<int> myqueue;

// pushing elements into queue using push()
myqueue.push(0);
myqueue.push(1);
myqueue.push(2);

// print contents of queue
while (!myqueue.empty()) {
cout << ' ' << myqueue.front();
myqueue.pop();
}
```

0 comments on commit 555c651

Please sign in to comment.