jtentor icon

DemoQueue4 - SpecialQueue.h

jtentor | PRO | 05/17/20 03:51:10 PM UTC | 0 ⭐ | 1484 👁️ | Never ⏰ | []
C++ |

770 B

|

None

|

0 👍

/

0 👎

//
// Created by Julio Tentor <[email protected]>
//
 
#ifndef DEMOQUEUE4_SPECIALQUEUE_H
#define DEMOQUEUE4_SPECIALQUEUE_H
 
#include <queue>
#include <deque>
 
template <class ELEMENT>
class specialqueue: public std::queue<ELEMENT, std::deque<ELEMENT>> {
public:
    specialqueue<ELEMENT> join(specialqueue<ELEMENT> & other);
};
 
template<class ELEMENT>
specialqueue<ELEMENT> specialqueue<ELEMENT>::join(specialqueue<ELEMENT> & other) {
    specialqueue<ELEMENT> result = specialqueue<ELEMENT>();
 
    for (auto it = this->c.begin(); it != this->c.end(); ++it) {
        result.push(*it);
    }
 
    for (auto it = other.c.begin(); it != other.c.end(); ++it) {
        result.push(*it);
    }
 
    return result;
}
 
#endif //DEMOQUEUE4_SPECIALQUEUE_H

Comments