STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
priority_queue.hpp
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 // Copyright (C) 2005-2013 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 3, or (at your option) any later
9 // version.
10 
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
26 
27 // Permission to use, copy, modify, sell, and distribute this software
28 // is hereby granted without fee, provided that the above copyright
29 // notice appears in all copies, and that both that copyright notice
30 // and this permission notice appear in supporting documentation. None
31 // of the above authors, nor IBM Haifa Research Laboratories, make any
32 // representation about the suitability of this software for any
33 // purpose. It is provided "as is" without express or implied
34 // warranty.
35 
41 #ifndef PB_DS_PRIORITY_QUEUE_HPP
42 #define PB_DS_PRIORITY_QUEUE_HPP
43 
44 #include <bits/c++config.h>
48 
49 namespace __gnu_pbds
50 {
79  template<typename _Tv,
80  typename Cmp_Fn = std::less<_Tv>,
81  typename Tag = pairing_heap_tag,
82  typename _Alloc = std::allocator<char> >
84  : public detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc, Tag>::type
85  {
86  public:
87  typedef _Tv value_type;
88  typedef Cmp_Fn cmp_fn;
89  typedef Tag container_category;
90  typedef _Alloc allocator_type;
91  typedef typename allocator_type::size_type size_type;
92  typedef typename allocator_type::difference_type difference_type;
93 
94  private:
95  typedef typename detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc,
96  Tag>::type
98  typedef typename _Alloc::template rebind<_Tv> __rebind_v;
99  typedef typename __rebind_v::other __rebind_va;
100 
101  public:
102  typedef typename __rebind_va::reference reference;
103  typedef typename __rebind_va::const_reference const_reference;
104  typedef typename __rebind_va::pointer pointer;
105  typedef typename __rebind_va::const_pointer const_pointer;
106 
107  typedef typename base_type::point_iterator point_iterator;
108  typedef typename base_type::point_const_iterator point_const_iterator;
109  typedef typename base_type::iterator iterator;
110  typedef typename base_type::const_iterator const_iterator;
111 
113 
116  priority_queue(const cmp_fn& r_cmp_fn) : base_type(r_cmp_fn) { }
117 
121  template<typename It>
122  priority_queue(It first_it, It last_it)
123  { base_type::copy_from_range(first_it, last_it); }
124 
129  template<typename It>
130  priority_queue(It first_it, It last_it, const cmp_fn& r_cmp_fn)
131  : base_type(r_cmp_fn)
132  { base_type::copy_from_range(first_it, last_it); }
133 
135  : base_type((const base_type& )other) { }
136 
137  virtual
139 
141  operator=(const priority_queue& other)
142  {
143  if (this != &other)
144  {
145  priority_queue tmp(other);
146  swap(tmp);
147  }
148  return *this;
149  }
150 
151  void
153  { base_type::swap(other); }
154  };
155 } // namespace __gnu_pbds
157 #endif
Tag container_category
Definition: priority_queue.hpp:89
__rebind_va::pointer pointer
Definition: priority_queue.hpp:104
priority_queue(const cmp_fn &r_cmp_fn)
Definition: priority_queue.hpp:116
Cmp_Fn cmp_fn
Definition: priority_queue.hpp:88
detail::container_base_dispatch< _Tv, Cmp_Fn, _Alloc, Tag >::type base_type
Definition: priority_queue.hpp:97
base_type::point_const_iterator point_const_iterator
Definition: priority_queue.hpp:108
priority_queue & operator=(const priority_queue &other)
Definition: priority_queue.hpp:141
__rebind_va::const_pointer const_pointer
Definition: priority_queue.hpp:105
base_type::iterator iterator
Definition: priority_queue.hpp:109
__rebind_v::other __rebind_va
Definition: priority_queue.hpp:99
__rebind_va::const_reference const_reference
Definition: priority_queue.hpp:103
allocator_type::difference_type difference_type
Definition: priority_queue.hpp:92
priority_queue()
Definition: priority_queue.hpp:112
priority_queue(It first_it, It last_it)
Definition: priority_queue.hpp:122
base_type::const_iterator const_iterator
Definition: priority_queue.hpp:110
priority_queue(const priority_queue &other)
Definition: priority_queue.hpp:134
_Alloc allocator_type
Definition: priority_queue.hpp:90
Definition: priority_queue.hpp:83
base_type::point_iterator point_iterator
Definition: priority_queue.hpp:107
__rebind_va::reference reference
Definition: priority_queue.hpp:102
Dispatch mechanism, primary template for associative types.
Definition: tag_and_trait.hpp:449
void swap(priority_queue &other)
Definition: priority_queue.hpp:152
priority_queue(It first_it, It last_it, const cmp_fn &r_cmp_fn)
Definition: priority_queue.hpp:130
allocator_type::size_type size_type
Definition: priority_queue.hpp:91
virtual ~priority_queue()
Definition: priority_queue.hpp:138
_Tv value_type
Definition: priority_queue.hpp:87
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160
_Alloc::template rebind< _Tv > __rebind_v
Definition: priority_queue.hpp:98