aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_')
-rw-r--r--gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp82
-rw-r--r--gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp53
-rw-r--r--gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp233
-rw-r--r--gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp49
-rw-r--r--gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp88
-rw-r--r--gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp185
-rw-r--r--gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp123
7 files changed, 813 insertions, 0 deletions
diff --git a/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp
new file mode 100644
index 0000000..6208432
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp
@@ -0,0 +1,82 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library 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
+// General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file pairing_heap_/constructors_destructor_fn_imps.hpp
+ * Contains an implementation class for a pairing heap.
+ */
+
+PB_DS_CLASS_T_DEC
+template<typename It>
+void
+PB_DS_CLASS_C_DEC::
+copy_from_range(It first_it, It last_it)
+{
+ while (first_it != last_it)
+ push(*(first_it++));
+ PB_DS_ASSERT_VALID((*this))
+}
+
+PB_DS_CLASS_T_DEC
+PB_DS_CLASS_C_DEC::
+pairing_heap()
+{ PB_DS_ASSERT_VALID((*this)) }
+
+PB_DS_CLASS_T_DEC
+PB_DS_CLASS_C_DEC::
+pairing_heap(const Cmp_Fn& r_cmp_fn)
+: base_type(r_cmp_fn)
+{ PB_DS_ASSERT_VALID((*this)) }
+
+PB_DS_CLASS_T_DEC
+PB_DS_CLASS_C_DEC::
+pairing_heap(const PB_DS_CLASS_C_DEC& other)
+: base_type(other)
+{ PB_DS_ASSERT_VALID((*this)) }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+swap(PB_DS_CLASS_C_DEC& other)
+{
+ PB_DS_ASSERT_VALID((*this))
+ base_type::swap(other);
+ PB_DS_ASSERT_VALID((*this))
+}
+
+PB_DS_CLASS_T_DEC
+PB_DS_CLASS_C_DEC::
+~pairing_heap()
+{ }
diff --git a/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp
new file mode 100644
index 0000000..a662c18
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library 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
+// General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file pairing_heap_/debug_fn_imps.hpp
+ * Contains an implementation class for a pairing heap.
+ */
+
+#ifdef _GLIBCXX_DEBUG
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+assert_valid(const char* __file, int __line) const
+{
+ PB_DS_DEBUG_VERIFY(base_type::m_p_root == 0
+ || base_type::m_p_root->m_p_next_sibling == 0);
+ base_type::assert_valid(__file, __line);
+}
+
+#endif
diff --git a/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp
new file mode 100644
index 0000000..4282032
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp
@@ -0,0 +1,233 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library 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
+// General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file pairing_heap_/erase_fn_imps.hpp
+ * Contains an implementation class for a pairing heap.
+ */
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+pop()
+{
+ PB_DS_ASSERT_VALID((*this))
+ _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
+
+ node_pointer p_new_root = join_node_children(base_type::m_p_root);
+ PB_DS_ASSERT_NODE_CONSISTENT(p_new_root, false)
+ if (p_new_root != 0)
+ p_new_root->m_p_prev_or_parent = 0;
+
+ base_type::actual_erase_node(base_type::m_p_root);
+ base_type::m_p_root = p_new_root;
+ PB_DS_ASSERT_VALID((*this))
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+erase(point_iterator it)
+{
+ PB_DS_ASSERT_VALID((*this))
+ _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
+ remove_node(it.m_p_nd);
+ base_type::actual_erase_node(it.m_p_nd);
+ PB_DS_ASSERT_VALID((*this))
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+remove_node(node_pointer p_nd)
+{
+ PB_DS_ASSERT_VALID((*this))
+ _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
+ node_pointer p_new_child = join_node_children(p_nd);
+
+ PB_DS_ASSERT_NODE_CONSISTENT(p_new_child, false)
+
+ if (p_nd == base_type::m_p_root)
+ {
+ if (p_new_child != 0)
+ p_new_child->m_p_prev_or_parent = 0;
+ base_type::m_p_root = p_new_child;
+ PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
+ return;
+ }
+
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_prev_or_parent != 0);
+ if (p_nd->m_p_prev_or_parent->m_p_l_child == p_nd)
+ {
+ if (p_new_child != 0)
+ {
+ p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
+ p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling;
+ if (p_new_child->m_p_next_sibling != 0)
+ p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child;
+ p_nd->m_p_prev_or_parent->m_p_l_child = p_new_child;
+ PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
+ return;
+ }
+
+ p_nd->m_p_prev_or_parent->m_p_l_child = p_nd->m_p_next_sibling;
+ if (p_nd->m_p_next_sibling != 0)
+ p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
+ PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
+ return;
+ }
+
+ if (p_new_child != 0)
+ {
+ p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
+ p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling;
+ if (p_new_child->m_p_next_sibling != 0)
+ p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child;
+ p_new_child->m_p_prev_or_parent->m_p_next_sibling = p_new_child;
+ PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
+ return;
+ }
+
+ p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling;
+ if (p_nd->m_p_next_sibling != 0)
+ p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
+ PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false)
+}
+
+PB_DS_CLASS_T_DEC
+typename PB_DS_CLASS_C_DEC::node_pointer
+PB_DS_CLASS_C_DEC::
+join_node_children(node_pointer p_nd)
+{
+ _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
+ node_pointer p_ret = p_nd->m_p_l_child;
+ if (p_ret == 0)
+ return 0;
+ while (p_ret->m_p_next_sibling != 0)
+ p_ret = forward_join(p_ret, p_ret->m_p_next_sibling);
+ while (p_ret->m_p_prev_or_parent != p_nd)
+ p_ret = back_join(p_ret->m_p_prev_or_parent, p_ret);
+ PB_DS_ASSERT_NODE_CONSISTENT(p_ret, false)
+ return p_ret;
+}
+
+PB_DS_CLASS_T_DEC
+typename PB_DS_CLASS_C_DEC::node_pointer
+PB_DS_CLASS_C_DEC::
+forward_join(node_pointer p_nd, node_pointer p_next)
+{
+ _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
+ _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling == p_next);
+ if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
+ {
+ p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
+ base_type::make_child_of(p_nd, p_next);
+ return p_next->m_p_next_sibling == 0
+ ? p_next : p_next->m_p_next_sibling;
+ }
+
+ if (p_next->m_p_next_sibling != 0)
+ {
+ p_next->m_p_next_sibling->m_p_prev_or_parent = p_nd;
+ p_nd->m_p_next_sibling = p_next->m_p_next_sibling;
+ base_type::make_child_of(p_next, p_nd);
+ return p_nd->m_p_next_sibling;
+ }
+
+ p_nd->m_p_next_sibling = 0;
+ base_type::make_child_of(p_next, p_nd);
+ PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
+ return p_nd;
+}
+
+PB_DS_CLASS_T_DEC
+typename PB_DS_CLASS_C_DEC::node_pointer
+PB_DS_CLASS_C_DEC::
+back_join(node_pointer p_nd, node_pointer p_next)
+{
+ _GLIBCXX_DEBUG_ASSERT(p_nd != 0);
+ _GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == 0);
+
+ if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
+ {
+ p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
+ base_type::make_child_of(p_nd, p_next);
+ PB_DS_ASSERT_NODE_CONSISTENT(p_next, false)
+ return p_next;
+ }
+
+ p_nd->m_p_next_sibling = 0;
+ base_type::make_child_of(p_next, p_nd);
+ PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
+ return p_nd;
+}
+
+PB_DS_CLASS_T_DEC
+template<typename Pred>
+typename PB_DS_CLASS_C_DEC::size_type
+PB_DS_CLASS_C_DEC::
+erase_if(Pred pred)
+{
+ PB_DS_ASSERT_VALID((*this))
+ if (base_type::empty())
+ {
+ PB_DS_ASSERT_VALID((*this))
+ return 0;
+ }
+ base_type::to_linked_list();
+ node_pointer p_out = base_type::prune(pred);
+ size_type ersd = 0;
+ while (p_out != 0)
+ {
+ ++ersd;
+ node_pointer p_next = p_out->m_p_next_sibling;
+ base_type::actual_erase_node(p_out);
+ p_out = p_next;
+ }
+
+ node_pointer p_cur = base_type::m_p_root;
+ base_type::m_p_root = 0;
+ while (p_cur != 0)
+ {
+ node_pointer p_next = p_cur->m_p_next_sibling;
+ p_cur->m_p_l_child = p_cur->m_p_next_sibling = p_cur->m_p_prev_or_parent = 0;
+
+ push_imp(p_cur);
+ p_cur = p_next;
+ }
+ PB_DS_ASSERT_VALID((*this))
+ return ersd;
+}
+
diff --git a/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp
new file mode 100644
index 0000000..b346c9a
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library 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
+// General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file pairing_heap_/find_fn_imps.hpp
+ * Contains an implementation class for a pairing heap.
+ */
+
+PB_DS_CLASS_T_DEC
+inline typename PB_DS_CLASS_C_DEC::const_reference
+PB_DS_CLASS_C_DEC::
+top() const
+{
+ PB_DS_ASSERT_VALID((*this))
+ _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
+ return base_type::m_p_root->m_value;
+}
diff --git a/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp
new file mode 100644
index 0000000..9903767
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp
@@ -0,0 +1,88 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library 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
+// General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file pairing_heap_/insert_fn_imps.hpp
+ * Contains an implementation class for a pairing heap.
+ */
+
+PB_DS_CLASS_T_DEC
+inline typename PB_DS_CLASS_C_DEC::point_iterator
+PB_DS_CLASS_C_DEC::
+push(const_reference r_val)
+{
+ PB_DS_ASSERT_VALID((*this))
+ node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val);
+ push_imp(p_new_nd);
+ PB_DS_ASSERT_VALID((*this))
+ return point_iterator(p_new_nd);
+}
+
+PB_DS_CLASS_T_DEC
+inline void
+PB_DS_CLASS_C_DEC::
+push_imp(node_pointer p_nd)
+{
+ p_nd->m_p_l_child = 0;
+ if (base_type::m_p_root == 0)
+ {
+ p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0;
+ base_type::m_p_root = p_nd;
+ }
+ else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value))
+ {
+ p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0;
+ base_type::make_child_of(base_type::m_p_root, p_nd);
+ PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false)
+ base_type::m_p_root = p_nd;
+ }
+ else
+ {
+ base_type::make_child_of(p_nd, base_type::m_p_root);
+ PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+modify(point_iterator it, const_reference r_new_val)
+{
+ PB_DS_ASSERT_VALID((*this))
+ remove_node(it.m_p_nd);
+ it.m_p_nd->m_value = r_new_val;
+ push_imp(it.m_p_nd);
+ PB_DS_ASSERT_VALID((*this))
+}
diff --git a/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp
new file mode 100644
index 0000000..dc32a88
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp
@@ -0,0 +1,185 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library 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
+// General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file pairing_heap_/pairing_heap_.hpp
+ * Contains an implementation class for a pairing heap.
+ */
+
+/*
+ * Pairing heap:
+ * Michael L. Fredman, Robert Sedgewick, Daniel Dominic Sleator,
+ * and Robert Endre Tarjan, The Pairing Heap:
+ * A New Form of Self-Adjusting Heap, Algorithmica, 1(1):111-129, 1986.
+ */
+
+#include <ext/pb_ds/detail/cond_dealtor.hpp>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp>
+#include <debug/debug.h>
+
+namespace __gnu_pbds
+{
+ namespace detail
+ {
+#define PB_DS_CLASS_T_DEC \
+ template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
+
+#define PB_DS_CLASS_C_DEC \
+ pairing_heap<Value_Type, Cmp_Fn, _Alloc>
+
+#ifdef _GLIBCXX_DEBUG
+#define PB_DS_P_HEAP_BASE \
+ left_child_next_sibling_heap<Value_Type, Cmp_Fn, null_type, _Alloc, false>
+#else
+#define PB_DS_P_HEAP_BASE \
+ left_child_next_sibling_heap<Value_Type, Cmp_Fn, null_type, _Alloc>
+#endif
+
+ /**
+ * Pairing heap.
+ *
+ * @ingroup heap-detail
+ */
+ template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
+ class pairing_heap : public PB_DS_P_HEAP_BASE
+ {
+ private:
+ typedef PB_DS_P_HEAP_BASE base_type;
+ typedef typename base_type::node_pointer node_pointer;
+
+ typedef typename _Alloc::template rebind<Value_Type>::other __rebind_a;
+
+ public:
+ typedef Value_Type value_type;
+ typedef Cmp_Fn cmp_fn;
+ typedef _Alloc allocator_type;
+ typedef typename _Alloc::size_type size_type;
+ typedef typename _Alloc::difference_type difference_type;
+
+ typedef typename __rebind_a::pointer pointer;
+ typedef typename __rebind_a::const_pointer const_pointer;
+ typedef typename __rebind_a::reference reference;
+ typedef typename __rebind_a::const_reference const_reference;
+
+ typedef typename base_type::point_const_iterator point_const_iterator;
+ typedef typename base_type::point_iterator point_iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::iterator iterator;
+
+ pairing_heap();
+
+ pairing_heap(const Cmp_Fn&);
+
+ pairing_heap(const pairing_heap&);
+
+ void
+ swap(pairing_heap&);
+
+ ~pairing_heap();
+
+ inline point_iterator
+ push(const_reference);
+
+ void
+ modify(point_iterator, const_reference);
+
+ inline const_reference
+ top() const;
+
+ void
+ pop();
+
+ void
+ erase(point_iterator);
+
+ template<typename Pred>
+ size_type
+ erase_if(Pred);
+
+ template<typename Pred>
+ void
+ split(Pred, pairing_heap&);
+
+ void
+ join(pairing_heap&);
+
+ protected:
+
+ template<typename It>
+ void
+ copy_from_range(It, It);
+
+#ifdef _GLIBCXX_DEBUG
+ void
+ assert_valid(const char*, int) const;
+#endif
+
+ private:
+
+ inline void
+ push_imp(node_pointer);
+
+ node_pointer
+ join_node_children(node_pointer);
+
+ node_pointer
+ forward_join(node_pointer, node_pointer);
+
+ node_pointer
+ back_join(node_pointer, node_pointer);
+
+ void
+ remove_node(node_pointer);
+ };
+
+#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \
+ _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, _Bool, \
+ __FILE__, __LINE__);)
+
+#include <ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp>
+#include <ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp>
+#include <ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp>
+#include <ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp>
+#include <ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp>
+#include <ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp>
+
+#undef PB_DS_ASSERT_NODE_CONSISTENT
+#undef PB_DS_CLASS_C_DEC
+#undef PB_DS_CLASS_T_DEC
+#undef PB_DS_P_HEAP_BASE
+
+ } // namespace detail
+} // namespace __gnu_pbds
diff --git a/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp
new file mode 100644
index 0000000..a2a4312
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp
@@ -0,0 +1,123 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005-2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library 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
+// General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file pairing_heap_/split_join_fn_imps.hpp
+ * Contains an implementation class for a pairing heap.
+ */
+
+PB_DS_CLASS_T_DEC
+template<typename Pred>
+void
+PB_DS_CLASS_C_DEC::
+split(Pred pred, PB_DS_CLASS_C_DEC& other)
+{
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
+
+ other.clear();
+
+ if (base_type::empty())
+ {
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
+ return;
+ }
+
+ base_type::to_linked_list();
+ node_pointer p_out = base_type::prune(pred);
+ while (p_out != 0)
+ {
+ _GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0);
+ --base_type::m_size;
+ ++other.m_size;
+ node_pointer p_next = p_out->m_p_next_sibling;
+ p_out->m_p_l_child = p_out->m_p_next_sibling = p_out->m_p_prev_or_parent = 0;
+
+ other.push_imp(p_out);
+ p_out = p_next;
+ }
+
+ PB_DS_ASSERT_VALID(other)
+ node_pointer p_cur = base_type::m_p_root;
+ base_type::m_p_root = 0;
+ while (p_cur != 0)
+ {
+ node_pointer p_next = p_cur->m_p_next_sibling;
+ p_cur->m_p_l_child = p_cur->m_p_next_sibling = p_cur->m_p_prev_or_parent = 0;
+
+ push_imp(p_cur);
+ p_cur = p_next;
+ }
+
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
+}
+
+PB_DS_CLASS_T_DEC
+inline void
+PB_DS_CLASS_C_DEC::
+join(PB_DS_CLASS_C_DEC& other)
+{
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
+
+ if (other.m_p_root == 0)
+ {
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
+ return;
+ }
+
+ if (base_type::m_p_root == 0)
+ base_type::m_p_root = other.m_p_root;
+ else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value))
+ {
+ base_type::make_child_of(base_type::m_p_root, other.m_p_root);
+ PB_DS_ASSERT_NODE_CONSISTENT(other.m_p_root, false)
+ base_type::m_p_root = other.m_p_root;
+ }
+ else
+ {
+ base_type::make_child_of(other.m_p_root, base_type::m_p_root);
+ PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false)
+ }
+
+ base_type::m_size += other.m_size;
+ other.m_p_root = 0;
+ other.m_size = 0;
+ PB_DS_ASSERT_VALID((*this))
+ PB_DS_ASSERT_VALID(other)
+}