crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
Queue.hpp
Go to the documentation of this file.
1 /*
2  *
3  * ---
4  *
5  * Copyright (C) 2021 Anselm Schmidt (ans[ät]ohai.su)
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version in addition to the terms of any
11  * licences already herein identified.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  *
21  * ---
22  *
23  * Queue.hpp
24  *
25  * Helper function templates for queues.
26  *
27  * Created on: Feb 8, 2021
28  * Author: ans
29  */
30 
31 #ifndef HELPER_QUEUE_HPP_
32 #define HELPER_QUEUE_HPP_
33 
34 #include <queue> // std::queue
35 #include <stack> // std::stack
36 
39 
40  /*
41  * DECLARATION
42  */
43 
46 
48 
53  template<typename T> void reverse(std::queue<T>& queue) {
54  std::stack<T> stack;
55 
56  while(!queue.empty()) {
57  stack.push(queue.front());
58 
59  queue.pop();
60  }
61 
62  while(!stack.empty()) {
63  queue.push(stack.top());
64 
65  stack.pop();
66  }
67  }
68 
70 
71  /*
72  * IMPLEMENTATION
73  */
74 
75  /* nothing to see here */
76 
77 } /* namespace crawlservpp::Helper::Queue */
78 
79 #endif /* HELPER_QUEUE_HPP_ */
void reverse(std::queue< T > &queue)
Reverses the given queue.
Definition: Queue.hpp:53
Namespace for global queue helper function templates.
Definition: Queue.hpp:38