1
 
/*      Copyright (C) 2004 Garrett A. Kajmowicz
 
2
 
        This file is part of the uClibc++ Library.
 
3
 
        This library is free software; you can redistribute it and/or
 
4
 
        modify it under the terms of the GNU Lesser General Public
 
5
 
        License as published by the Free Software Foundation; either
 
6
 
        version 2.1 of the License, or (at your option) any later version.
 
8
 
        This library is distributed in the hope that it will be useful,
 
9
 
        but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 
        Lesser General Public License for more details.
 
13
 
        You should have received a copy of the GNU Lesser General Public
 
14
 
        License along with this library; if not, write to the Free Software
 
15
 
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 
#include <basic_definitions>
 
23
 
#ifndef __HEADER_STD_QUEUE
 
24
 
#define __HEADER_STD_QUEUE 1
 
26
 
#pragma GCC visibility push(default)
 
30
 
        template <class T, class Container = deque<T> > class _UCXXEXPORT queue{
 
34
 
                typedef typename Container::value_type  value_type;
 
35
 
                typedef typename Container::size_type   size_type;
 
36
 
                typedef Container                       container_type;
 
38
 
                explicit queue(const Container& a = Container()) : c(a) {  }
 
40
 
                bool empty() const              { return c.empty(); }
 
41
 
                size_type size()  const         { return c.size(); }
 
42
 
                value_type&       front()       { return c.front(); }
 
43
 
                const value_type& front() const { return c.front(); }
 
44
 
                value_type&       back()        { return c.back(); }
 
45
 
                const value_type& back() const  { return c.back(); }
 
46
 
                void push(const value_type& x)  { c.push_back(x); }
 
47
 
                void pop()                      { c.pop_front(); }
 
51
 
        template <class T, class Container> _UCXXEXPORT bool
 
52
 
                operator==(const queue<T, Container>& x, const queue<T, Container>& y)
 
56
 
        template <class T, class Container> _UCXXEXPORT bool
 
57
 
                operator< (const queue<T, Container>& x, const queue<T, Container>& y)
 
61
 
        template <class T, class Container> _UCXXEXPORT bool
 
62
 
                operator!=(const queue<T, Container>& x, const queue<T, Container>& y)
 
66
 
        template <class T, class Container> _UCXXEXPORT bool
 
67
 
                operator> (const queue<T, Container>& x, const queue<T, Container>& y)
 
71
 
        template <class T, class Container> _UCXXEXPORT bool
 
72
 
                operator>=(const queue<T, Container>& x, const queue<T, Container>& y)
 
76
 
        template <class T, class Container> _UCXXEXPORT bool
 
77
 
                operator<=(const queue<T, Container>& x, const queue<T, Container>& y)
 
84
 
                class Container = vector<T>,
 
85
 
                class Compare = less<typename Container::value_type>
 
86
 
        > class _UCXXEXPORT priority_queue {
 
91
 
                typedef typename Container::value_type  value_type;
 
92
 
                typedef typename Container::size_type   size_type;
 
93
 
                typedef Container                       container_type;
 
95
 
                explicit priority_queue(const Compare& x = Compare(), const Container& a = Container())
 
96
 
                        : c(a), comp(x) { make_heap(c.begin(), c.end(), comp) ; }
 
97
 
                template <class InputIterator> priority_queue(InputIterator first,
 
99
 
                        const Compare& x = Compare(),
 
100
 
                        const Container& y= Container())
 
103
 
                        c.insert(c.end(), first, last);
 
104
 
                        make_heap(c.begin(), c.end(), comp);
 
107
 
                bool empty() const       { return c.empty(); }
 
108
 
                size_type size()  const       { return c.size(); }
 
109
 
                const value_type& top() const { return c.front(); }
 
110
 
                void push(const value_type& x){
 
112
 
                        push_heap(c.begin(), c.end(), comp);
 
115
 
                        pop_heap(c.begin(), c.end(), comp);
 
122
 
#pragma GCC visibility pop