Advertisement
jtentor

DemoQueue4 - SpecialQueue.h

May 17th, 2020
1,255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. //
  2. // Created by Julio Tentor <jtentor@fi.unju.edu.ar>
  3. //
  4.  
  5. #ifndef DEMOQUEUE4_SPECIALQUEUE_H
  6. #define DEMOQUEUE4_SPECIALQUEUE_H
  7.  
  8. #include <queue>
  9. #include <deque>
  10.  
  11. template <class ELEMENT>
  12. class specialqueue: public std::queue<ELEMENT, std::deque<ELEMENT>> {
  13. public:
  14.     specialqueue<ELEMENT> join(specialqueue<ELEMENT> & other);
  15. };
  16.  
  17. template<class ELEMENT>
  18. specialqueue<ELEMENT> specialqueue<ELEMENT>::join(specialqueue<ELEMENT> & other) {
  19.     specialqueue<ELEMENT> result = specialqueue<ELEMENT>();
  20.  
  21.     for (auto it = this->c.begin(); it != this->c.end(); ++it) {
  22.         result.push(*it);
  23.     }
  24.  
  25.     for (auto it = other.c.begin(); it != other.c.end(); ++it) {
  26.         result.push(*it);
  27.     }
  28.  
  29.     return result;
  30. }
  31.  
  32. #endif //DEMOQUEUE4_SPECIALQUEUE_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement