Files
pip/libs/main/containers/piqueue.h
Бычков Андрей 5a1a381a32 containers doc
2022-08-29 18:32:55 +03:00

55 lines
1.7 KiB
C++

//! \addtogroup Containers
//! \{
//! \file piqueue.h
//! \brief
//! \~english Declares \a PIQueue
//! \~russian Объявление \a PIQueue
//! \~\authors
//! \~english
//! Ivan Pelipenko peri4ko@yandex.ru;
//! Andrey Bychkov work.a.b@yandex.ru;
//! \~russian
//! Иван Пелипенко peri4ko@yandex.ru;
//! Андрей Бычков work.a.b@yandex.ru;
//! \~\}
/*
PIP - Platform Independent Primitives
Queue container
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIQUEUE_H
#define PIQUEUE_H
#include "pideque.h"
#include "pivector.h"
template<typename T>
class PIQueue: public PIDeque<T> {
public:
PIQueue() {}
PIDeque<T> & enqueue(const T & v) {PIDeque<T>::push_front(v); return *this;}
PIDeque<T> & enqueue(T && v) {PIDeque<T>::push_front(std::move(v)); return *this;}
T dequeue() {return PIDeque<T>::take_back();}
T & head() {return PIDeque<T>::back();}
const T & head() const {return PIDeque<T>::back();}
PIVector<T> toVector() {return PIVector<T>(PIDeque<T>::data(), PIDeque<T>::size());}
PIDeque<T> toDeque() {return PIDeque<T>(*this);}
};
#endif // PIQUEUE_H