/*  Copyright (C) 2015  Povilas Kanapickas <povilas@radix.lt>

    This file is part of cppreference-doc

    This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
    Unported License. To view a copy of this license, visit
    http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
    Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3 or
    any later version published by the Free Software Foundation; with no
    Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/

#ifndef CPPREFERENCE_QUEUE_H
#define CPPREFERENCE_QUEUE_H

#if CPPREFERENCE_STDVER>= 2011
#include <initializer_list>
#endif

namespace std {

template <
    class T,
    class Container = std::deque<T>
    > class queue {
public:
    typedef Container container_type;
    typedef typename Container::value_type value_type;
    typedef typename Container::size_type size_type;
    typedef typename Container::reference reference;
    typedef typename Container::const_reference const_reference;

#if CPPREFERENCE_STDVER <2011
    explicit queue(const Container& cont = Container());
#else
    explicit queue(const Container& cont);
    explicit queue(Container&& cont = Container());
    queue(const queue& other);
    queue(queue&& other);

    template<class Alloc>
    explicit queue(const Alloc& alloc);

    template<class Alloc>
    queue(const Container& cont, const Alloc& alloc);

    template<class Alloc>
    queue(Container&& cont, const Alloc& alloc);

    template<class Alloc>
    queue(const queue& other, const Alloc& alloc);

    template<class Alloc>
    queue(queue&& other, const Alloc& alloc);
#endif

    ~queue();

    queue<T, Container>&
    operator=(const queue<T, Container>& other);

#if CPPREFERENCE_STDVER>= 2011
    queue<T, Container>&
    operator=(queue<T, Container>&& other);
#endif

    reference front();
    const_reference front() const;

    reference back();
    const_reference back() const;

    bool empty() const;
    size_type size() const;

    void push(const T& value);

#if CPPREFERENCE_STDVER>= 2011
    void push(T&& value);
    template<class... Args>
    void emplace(Args&& ... args);
#endif

    void pop();

#if CPPREFERENCE_STDVER>= 2011
    void swap(queue& other);
#endif

protected:
    Container c;
};

template<class T, class Container>
bool operator==(queue<T, Container>& lhs,
                queue<T, Container>& rhs);

template<class T, class Container>
bool operator!=(queue<T, Container>& lhs,
                queue<T, Container>& rhs);

template<class T, class Container>
bool operator<(queue<T, Container>& lhs,
               queue<T, Container>& rhs);

template<class T, class Container>
bool operator<=(queue<T, Container>& lhs,
                queue<T, Container>& rhs);

template<class T, class Container>
bool operator>(queue<T, Container>& lhs,
               queue<T, Container>& rhs);

template<class T, class Container>
bool operator>=(queue<T, Container>& lhs,
                queue<T, Container>& rhs);

template<class T, class Container>
void swap(queue<T, Container>& lhs,
          queue<T, Container>& rhs);


template <
    class T,
    class Container = std::vector<T>,
    class Compare = std::less<typename Container::value_type>
    > class priority_queue {
public:
    typedef Container container_type;
    typedef typename Container::value_type value_type;
    typedef typename Container::size_type size_type;
    typedef typename Container::reference reference;
    typedef typename Container::const_reference const_reference;

    priority_queue(const priority_queue& other);
#if CPPREFERENCE_STDVER <2011
    explicit priority_queue(const Compare& compare = Compare(),
                            const Container& cont = Container());
#else
    priority_queue(const Compare& compare, const Container& cont);

    explicit priority_queue(const Compare& compare = Compare(),
                            Container && cont = Container());

    priority_queue(priority_queue&& other);

    template<class Alloc>
    explicit priority_queue(const Alloc& alloc);

    template<class Alloc>
    priority_queue(const Compare& compare, const Alloc& alloc);

    template<class Alloc>
    priority_queue(const Compare& compare, const Container& cont,
                   const Alloc& alloc);

    template<class Alloc>
    priority_queue(const Compare& compare, Container&& cont,
                   const Alloc& alloc);

    template<class Alloc>
    priority_queue(const priority_queue& other, const Alloc& alloc);

    template<class Alloc>
    priority_queue(priority_queue&& other, const Alloc& alloc);

    template<class InputIt>
    priority_queue(InputIt first, InputIt last,
                   const Compare& compare, const Container& cont);

    template<class InputIt>
    priority_queue(InputIt first, InputIt last,
                   const Compare& compare = Compare(),
                   Container && cont = Container());
#endif

    ~priority_queue();

    priority_queue<T, Container>&
    operator=(const priority_queue<T, Container>& other);

#if CPPREFERENCE_STDVER>= 2011
    priority_queue<T, Container>&
    operator=(priority_queue<T, Container>&& other);
#endif

    const_reference top() const;

    bool empty() const;
    size_type size() const;

    void push(const T& value);

#if CPPREFERENCE_STDVER>= 2011
    void push(T&& value);
    template<class... Args>
    void emplace(Args&& ... args);
#endif

    void pop();

#if CPPREFERENCE_STDVER>= 2011
    void swap(priority_queue& other);
#endif

protected:
    Container c;
    Compare comp;
};

template<class T, class Container>
bool operator==(priority_queue<T, Container>& lhs,
                priority_queue<T, Container>& rhs);

template<class T, class Container>
bool operator!=(priority_queue<T, Container>& lhs,
                priority_queue<T, Container>& rhs);

template<class T, class Container>
bool operator<(priority_queue<T, Container>& lhs,
               priority_queue<T, Container>& rhs);

template<class T, class Container>
bool operator<=(priority_queue<T, Container>& lhs,
                priority_queue<T, Container>& rhs);

template<class T, class Container>
bool operator>(priority_queue<T, Container>& lhs,
               priority_queue<T, Container>& rhs);

template<class T, class Container>
bool operator>=(priority_queue<T, Container>& lhs,
                priority_queue<T, Container>& rhs);

template<class T, class Container, class Compare>
void swap(priority_queue<T, Container, Compare>& lhs,
          priority_queue<T, Container, Compare>& rhs);


} // namespace std

#endif // CPPREFERENCE_QUEUE_H
