1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <queue> #include <deque> #include <iostream> template<typename T, typename Container=std::deque<T> > class iterable_queue : public std::queue<T,Container> { public: typedef typename Container::iterator iterator; typedef typename Container::const_iterator const_iterator; iterator begin() { return this->c.begin(); } iterator end() { return this->c.end(); } const_iterator begin() const { return this->c.begin(); } const_iterator end() const { return this->c.end(); } }; int main() { iterable_queue<int> int_queue; for(int i=0; i<10; ++i) int_queue.push(i); for(auto it=int_queue.begin(); it!=int_queue.end();++it) std::cout << *it << "\n"; return 0; } |
I2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8ZGVxdWU+CiNpbmNsdWRlIDxpb3N0cmVhbT4KCiAgICB0ZW1wbGF0ZTx0eXBlbmFtZSBULCB0eXBlbmFtZSBDb250YWluZXI9c3RkOjpkZXF1ZTxUPiA+CiAgICBjbGFzcyBpdGVyYWJsZV9xdWV1ZSA6IHB1YmxpYyBzdGQ6OnF1ZXVlPFQsQ29udGFpbmVyPgogICAgewogICAgcHVibGljOgogICAgCXR5cGVkZWYgdHlwZW5hbWUgQ29udGFpbmVyOjppdGVyYXRvciBpdGVyYXRvcjsKICAgIAl0eXBlZGVmIHR5cGVuYW1lIENvbnRhaW5lcjo6Y29uc3RfaXRlcmF0b3IgY29uc3RfaXRlcmF0b3I7CgogICAgCWl0ZXJhdG9yIGJlZ2luKCkgeyByZXR1cm4gdGhpcy0+Yy5iZWdpbigpOyB9CiAgICAJaXRlcmF0b3IgZW5kKCkgeyByZXR1cm4gdGhpcy0+Yy5lbmQoKTsgfQogICAgCWNvbnN0X2l0ZXJhdG9yIGJlZ2luKCkgY29uc3QgeyByZXR1cm4gdGhpcy0+Yy5iZWdpbigpOyB9CiAgICAJY29uc3RfaXRlcmF0b3IgZW5kKCkgY29uc3QgeyByZXR1cm4gdGhpcy0+Yy5lbmQoKTsgfQogICAgfTsKCmludCBtYWluKCkgewogICAgaXRlcmFibGVfcXVldWU8aW50PiBpbnRfcXVldWU7CiAgICBmb3IoaW50IGk9MDsgaTwxMDsgKytpKQogICAgICAgIGludF9xdWV1ZS5wdXNoKGkpOwogICAgZm9yKGF1dG8gaXQ9aW50X3F1ZXVlLmJlZ2luKCk7IGl0IT1pbnRfcXVldWUuZW5kKCk7KytpdCkKICAgICAgICBzdGQ6OmNvdXQgPDwgKml0IDw8ICJcbiI7CiAgICByZXR1cm4gMDsKfQo=
-
upload with new input
-
result: Success time: 0s memory: 2964 kB returned value: 0
0 1 2 3 4 5 6 7 8 9


