onst_key_reference r_key) const { _GLIBCXX_DEBUG_ONLY(assert_valid();) entry_pointer p_e = find_imp(r_key); return const_point_iterator(p_e == NULL ? NULL: &p_e->m_value); } inline bool erase(const_key_reference); template inline size_type erase_if(Pred); void clear(); inline iterator begin(); inline const_iterator begin() const; inline iterator end(); inline const_iterator end() const; #ifdef _GLIBCXX_DEBUG void assert_valid() const; #endif #ifdef PB_DS_LU_MAP_TRACE_ void trace() const; #endif protected: template void copy_from_range(It, It); private: #ifdef PB_DS_DATA_TRUE_INDICATOR friend class iterator_; #endif friend class const_iterator_; inline entry_pointer allocate_new_entry(const_reference, false_type); inline entry_pointer allocate_new_entry(const_reference, true_type); template inline static void init_entry_metadata(entry_pointer, type_to_type); inline static void init_entry_metadata(entry_pointer, type_to_type); void deallocate_all(); void erase_next(entry_pointer); void actual_erase_entry(entry_pointer); void inc_it_state(const_pointer& r_p_value, entry_pointer& r_pos) const { r_pos = r_pos->m_p_next; r_p_value = (r_pos == NULL) ? NULL : &r_pos->m_value; } template inline static bool apply_update(entry_pointer, type_to_type); inline static bool apply_update(entry_pointer, type_to_type); inline entry_pointer find_imp(const_key_reference) const; static entry_allocator s_entry_allocator; static Eq_Fn s_eq_fn; static Update_Policy s_update_policy; static type_to_type s_metadata_type_indicator; static null_lu_metadata s_null_lu_metadata; mutable entry_pointer m_p_l; }; #include #include #include #include #include #include #include #include #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_TYPES_TRAITS_C_DEC #undef PB_DS_DEBUG_MAP_BASE_C_DEC #undef PB_DS_CLASS_NAME #undef PB_DS_V2F #undef PB_DS_EP2VP #undef PB_DS_V2S } // namespace detail } // namespace __gnu_pbds // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 info_fn_imps.hpp * Contains implementations of lu_map_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { return std::distance(begin(), end()); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: max_size() const { return s_entry_allocator.max_size(); } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: empty() const { return (m_p_l == NULL); } // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 trace_fn_imps.hpp * Contains implementations of lu_map_. */ #ifdef PB_DS_LU_MAP_TRACE_ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: trace() const { std::cerr << m_p_l << std::endl << std::endl; const_entry_pointer p_l = m_p_l; while (p_l != NULL) { std::cerr << PB_DS_V2F(p_l->m_value) << std::endl; p_l = p_l->m_p_next; } std::cerr << std::endl; } #endif // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 find_fn_imps.hpp * Contains implementations of lu_map_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::entry_pointer PB_DS_CLASS_C_DEC:: find_imp(const_key_reference r_key) const { if (m_p_l == NULL) return NULL; if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value))) { apply_update(m_p_l, s_metadata_type_indicator); _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) return m_p_l; } entry_pointer p_l = m_p_l; while (p_l->m_p_next != NULL) { entry_pointer p_next = p_l->m_p_next; if (s_eq_fn(r_key, PB_DS_V2F(p_next->m_value))) { if (apply_update(p_next, s_metadata_type_indicator)) { p_l->m_p_next = p_next->m_p_next; p_next->m_p_next = m_p_l; m_p_l = p_next; return m_p_l; } return p_next; } else p_l = p_next; } _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) return NULL; } PB_DS_CLASS_T_DEC template inline bool PB_DS_CLASS_C_DEC:: apply_update(entry_pointer p_l, type_to_type) { return s_update_policy(p_l->m_update_metadata); } PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: apply_update(entry_pointer, type_to_type) { return s_update_policy(s_null_lu_metadata); } // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 entry_metadata_base.hpp * Contains an implementation for a list update map. */ #ifndef PB_DS_LU_MAP_ENTRY_METADATA_BASE_HPP #define PB_DS_LU_MAP_ENTRY_METADATA_BASE_HPP namespace __gnu_pbds { namespace detail { template struct lu_map_entry_metadata_base { Metadata m_update_metadata; }; template<> struct lu_map_entry_metadata_base { }; } // namespace detail } // namespace __gnu_pbds #endif // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 debug_fn_imps.hpp * Contains implementations of cc_ht_map_'s debug-mode functions. */ #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_valid() const { size_type calc_size = 0; for (const_iterator it = begin(); it != end(); ++it) { debug_base::check_key_exists(PB_DS_V2F(*it)); ++calc_size; } debug_base::check_size(calc_size); } #endif // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 erase_fn_imps.hpp * Contains implementations of lu_map_. */ PB_DS_CLASS_T_DEC inline bool PB_DS_CLASS_C_DEC:: erase(const_key_reference r_key) { _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) if (m_p_l == NULL) return false; if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value))) { entry_pointer p_next = m_p_l->m_p_next; actual_erase_entry(m_p_l); m_p_l = p_next; return true; } entry_pointer p_l = m_p_l; while (p_l->m_p_next != NULL) if (s_eq_fn(r_key, PB_DS_V2F(p_l->m_p_next->m_value))) { erase_next(p_l); return true; } else p_l = p_l->m_p_next; return false; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: clear() { deallocate_all(); } PB_DS_CLASS_T_DEC template inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) size_type num_ersd = 0; while (m_p_l != NULL && pred(m_p_l->m_value)) { entry_pointer p_next = m_p_l->m_p_next; ++num_ersd; actual_erase_entry(m_p_l); m_p_l = p_next; } if (m_p_l == NULL) return num_ersd; entry_pointer p_l = m_p_l; while (p_l->m_p_next != NULL) { if (pred(p_l->m_p_next->m_value)) { ++num_ersd; erase_next(p_l); } else p_l = p_l->m_p_next; } _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) return num_ersd; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: erase_next(entry_pointer p_l) { _GLIBCXX_DEBUG_ASSERT(p_l != NULL); _GLIBCXX_DEBUG_ASSERT(p_l != m_p_l); _GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != NULL); entry_pointer p_next_l = p_l->m_p_next->m_p_next; actual_erase_entry(p_l->m_p_next); p_l->m_p_next = p_next_l; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: actual_erase_entry(entry_pointer p_l) { _GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_l->m_value));) p_l->~entry(); s_entry_allocator.deallocate(p_l, 1); } // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 iterators_fn_imps.hpp * Contains implementations of lu_map_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: begin() { if (m_p_l == NULL) { _GLIBCXX_DEBUG_ASSERT(empty()); return end(); } return iterator(&m_p_l->m_value, m_p_l, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: begin() const { if (m_p_l == NULL) { _GLIBCXX_DEBUG_ASSERT(empty()); return end(); } return iterator(&m_p_l->m_value, m_p_l, const_cast(this)); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: end() { return iterator(NULL, NULL, this); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: end() const { return const_iterator(NULL, NULL, const_cast(this)); } // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 constructor_destructor_fn_imps.hpp * Contains implementations of PB_DS_CLASS_NAME. */ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::entry_allocator PB_DS_CLASS_C_DEC::s_entry_allocator; PB_DS_CLASS_T_DEC Eq_Fn PB_DS_CLASS_C_DEC::s_eq_fn; PB_DS_CLASS_T_DEC null_lu_metadata PB_DS_CLASS_C_DEC::s_null_lu_metadata; PB_DS_CLASS_T_DEC Update_Policy PB_DS_CLASS_C_DEC::s_update_policy; PB_DS_CLASS_T_DEC type_to_type< typename PB_DS_CLASS_C_DEC::update_metadata> PB_DS_CLASS_C_DEC::s_metadata_type_indicator; PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) insert(*(first_it++)); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME() : m_p_l(NULL) { _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC template PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(It first_it, It last_it) : m_p_l(NULL) { copy_from_range(first_it, last_it); _GLIBCXX_DEBUG_ONLY(assert_valid();); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : #ifdef _GLIBCXX_DEBUG debug_base(), #endif m_p_l(NULL) { try { for (const_iterator it = other.begin(); it != other.end(); ++it) { entry_pointer p_l = allocate_new_entry(*it, PB_DS_TYPES_TRAITS_C_DEC::m_no_throw_copies_indicator); p_l->m_p_next = m_p_l; m_p_l = p_l; } } catch(...) { deallocate_all(); __throw_exception_again; } _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { _GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);) std::swap(m_p_l, other.m_p_l); _GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: deallocate_all() { entry_pointer p_l = m_p_l; while (p_l != NULL) { entry_pointer p_next_l = p_l->m_p_next; actual_erase_entry(p_l); p_l = p_next_l; } m_p_l = NULL; } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_CLASS_NAME() { deallocate_all(); } e .X ..f split_join_fn_imps.hppginsert_fn_imps.hpphinfo_fn_imps.hppisplay_fn_imps.hppjnode.hppkfind_fn_imps.hppl,#constructors_destructor_fn_imps.hppmdebug_fn_imps.hppnerase_fn_imps.hppo traits.hpppØsplay_tree_.hpp// -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 split_join_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { _GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();) if (base_type::join_prep(other) == false) { _GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } node_pointer p_target_r = other.leftmost(other.m_p_head); _GLIBCXX_DEBUG_ASSERT(p_target_r != NULL); other.splay(p_target_r); _GLIBCXX_DEBUG_ASSERT(p_target_r == other.m_p_head->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_left == NULL); p_target_r->m_p_left = base_type::m_p_head->m_p_parent; _GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_left != NULL); p_target_r->m_p_left->m_p_parent = p_target_r; base_type::m_p_head->m_p_parent = p_target_r; p_target_r->m_p_parent = base_type::m_p_head; apply_update(p_target_r, (node_update* )this); base_type::join_finish(other); _GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { _GLIBCXX_DEBUG_ONLY(assert_valid()); _GLIBCXX_DEBUG_ONLY(other.assert_valid()); if (base_type::split_prep(r_key, other) == false) { _GLIBCXX_DEBUG_ONLY(assert_valid()); _GLIBCXX_DEBUG_ONLY(other.assert_valid()); return; } node_pointer p_upper_bound = upper_bound(r_key).m_p_nd; _GLIBCXX_DEBUG_ASSERT(p_upper_bound != NULL); splay(p_upper_bound); _GLIBCXX_DEBUG_ASSERT(p_upper_bound->m_p_parent == this->m_p_head); node_pointer p_new_root = p_upper_bound->m_p_left; _GLIBCXX_DEBUG_ASSERT(p_new_root != NULL); base_type::m_p_head->m_p_parent = p_new_root; p_new_root->m_p_parent = base_type::m_p_head; other.m_p_head->m_p_parent = p_upper_bound; p_upper_bound->m_p_parent = other.m_p_head; p_upper_bound->m_p_left = NULL; apply_update(p_upper_bound, (node_update* )this); base_type::split_finish(other); _GLIBCXX_DEBUG_ONLY(assert_valid()); _GLIBCXX_DEBUG_ONLY(other.assert_valid()); } // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 insert_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert(const_reference r_value) { _GLIBCXX_DEBUG_ONLY(assert_valid();) std::pair ins_pair = insert_leaf_imp(r_value); ins_pair.first.m_p_nd->m_special = false; _GLIBCXX_DEBUG_ONLY(assert_valid()); splay(ins_pair.first.m_p_nd); _GLIBCXX_DEBUG_ONLY(assert_valid()); return ins_pair; } PB_DS_CLASS_T_DEC inline std::pair PB_DS_CLASS_C_DEC:: insert_leaf_imp(const_reference r_value) { _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) if (base_type::m_size == 0) return std::make_pair(base_type::insert_imp_empty(r_value), true); node_pointer p_nd = base_type::m_p_head->m_p_parent; node_pointer p_pot = base_type::m_p_head; while (p_nd != NULL) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_V2F(r_value))) { if (!Cmp_Fn::operator()(PB_DS_V2F(r_value), PB_DS_V2F(p_nd->m_value))) { return std::make_pair(point_iterator(p_nd), false); } p_pot = p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; if (p_pot == base_type::m_p_head) return std::make_pair(base_type::insert_leaf_new(r_value, base_type::m_p_head->m_p_right, false), true); _GLIBCXX_DEBUG_ONLY(base_type::check_key_does_not_exist(PB_DS_V2F(r_value))); p_nd = p_pot->m_p_left; if (p_nd == NULL) return (std::make_pair(base_type::insert_leaf_new(r_value, p_pot, true), true)); while (p_nd->m_p_right != NULL) p_nd = p_nd->m_p_right; return std::make_pair(insert_leaf_new(r_value, p_nd, false), true); } // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 info_fn_imps.hpp * Contains an implementation. */ // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 splay_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: splay(node_pointer p_nd) { while (p_nd->m_p_parent != base_type::m_p_head) { #ifdef _GLIBCXX_DEBUG { node_pointer p_head = base_type::m_p_head; assert_special_imp(p_head); } #endif _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);) if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head) { base_type::rotate_parent(p_nd); _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); } else { const node_pointer p_parent = p_nd->m_p_parent; const node_pointer p_grandparent = p_parent->m_p_parent; #ifdef _GLIBCXX_DEBUG const size_type total = base_type::recursive_count(p_grandparent); _GLIBCXX_DEBUG_ASSERT(total >= 3); #endif if (p_parent->m_p_left == p_nd && p_grandparent->m_p_right == p_parent) splay_zig_zag_left(p_nd, p_parent, p_grandparent); else if (p_parent->m_p_right == p_nd && p_grandparent->m_p_left == p_parent) splay_zig_zag_right(p_nd, p_parent, p_grandparent); else if (p_parent->m_p_left == p_nd && p_grandparent->m_p_left == p_parent) splay_zig_zig_left(p_nd, p_parent, p_grandparent); else splay_zig_zig_right(p_nd, p_parent, p_grandparent); _GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd)); } _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);) } } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && p_grandparent->m_p_right == p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); node_pointer p_b = p_nd->m_p_right; node_pointer p_c = p_nd->m_p_left; p_nd->m_p_right = p_parent; p_parent->m_p_parent = p_nd; p_nd->m_p_left = p_grandparent; p_grandparent->m_p_parent = p_nd; p_parent->m_p_left = p_b; if (p_b != NULL) p_b->m_p_parent = p_parent; p_grandparent->m_p_right = p_c; if (p_c != NULL) p_c->m_p_parent = p_grandparent; splay_zz_end(p_nd, p_parent, p_grandparent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && p_grandparent->m_p_left == p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); node_pointer p_b = p_nd->m_p_left; node_pointer p_c = p_nd->m_p_right; p_nd->m_p_left = p_parent; p_parent->m_p_parent = p_nd; p_nd->m_p_right = p_grandparent; p_grandparent->m_p_parent = p_nd; p_parent->m_p_right = p_b; if (p_b != NULL) p_b->m_p_parent = p_parent; p_grandparent->m_p_left = p_c; if (p_c != NULL) p_c->m_p_parent = p_grandparent; splay_zz_end(p_nd, p_parent, p_grandparent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && p_nd->m_p_parent->m_p_parent->m_p_left == p_nd->m_p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); node_pointer p_b = p_nd->m_p_right; node_pointer p_c = p_parent->m_p_right; p_nd->m_p_right = p_parent; p_parent->m_p_parent = p_nd; p_parent->m_p_right = p_grandparent; p_grandparent->m_p_parent = p_parent; p_parent->m_p_left = p_b; if (p_b != NULL) p_b->m_p_parent = p_parent; p_grandparent->m_p_left = p_c; if (p_c != NULL) p_c->m_p_parent = p_grandparent; splay_zz_end(p_nd, p_parent, p_grandparent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent); splay_zz_start(p_nd, p_parent, p_grandparent); node_pointer p_b = p_nd->m_p_left; node_pointer p_c = p_parent->m_p_left; p_nd->m_p_left = p_parent; p_parent->m_p_parent = p_nd; p_parent->m_p_left = p_grandparent; p_grandparent->m_p_parent = p_parent; p_parent->m_p_right = p_b; if (p_b != NULL) p_b->m_p_parent = p_parent; p_grandparent->m_p_right = p_c; if (p_c != NULL) p_c->m_p_parent = p_grandparent; base_type::update_to_top(p_grandparent, (node_update* )this); splay_zz_end(p_nd, p_parent, p_grandparent); } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zz_start(node_pointer p_nd, #ifdef _GLIBCXX_DEBUG node_pointer p_parent, #else node_pointer /*p_parent*/, #endif node_pointer p_grandparent) { _GLIBCXX_DEBUG_ASSERT(p_nd != NULL); _GLIBCXX_DEBUG_ASSERT(p_parent != NULL); _GLIBCXX_DEBUG_ASSERT(p_grandparent != NULL); const bool grandparent_head = p_grandparent->m_p_parent == base_type::m_p_head; if (grandparent_head) { base_type::m_p_head->m_p_parent = base_type::m_p_head->m_p_parent; p_nd->m_p_parent = base_type::m_p_head; return; } node_pointer p_greatgrandparent = p_grandparent->m_p_parent; p_nd->m_p_parent = p_greatgrandparent; if (p_grandparent == p_greatgrandparent->m_p_left) p_greatgrandparent->m_p_left = p_nd; else p_greatgrandparent->m_p_right = p_nd; } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: splay_zz_end(node_pointer p_nd, node_pointer p_parent, node_pointer p_grandparent) { if (p_nd->m_p_parent == base_type::m_p_head) base_type::m_p_head->m_p_parent = p_nd; apply_update(p_grandparent, (node_update* )this); apply_update(p_parent, (node_update* )this); apply_update(p_nd, (node_update* )this); _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);) } // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 node.hpp * Contains an implementation struct for splay_tree_'s node. */ #ifndef PB_DS_SPLAY_TREE_NODE_HPP #define PB_DS_SPLAY_TREE_NODE_HPP namespace __gnu_pbds { namespace detail { template struct splay_tree_node_ { public: typedef Value_Type value_type; typedef Metadata metadata_type; typedef typename Allocator::template rebind< splay_tree_node_ >::other::pointer node_pointer; typedef typename Allocator::template rebind::other::reference metadata_reference; typedef typename Allocator::template rebind::other::const_reference const_metadata_reference; #ifdef PB_DS_BIN_SEARCH_TREE_TRACE_ void trace() const { std::cout << PB_DS_V2F(m_value) << "(" << m_metadata << ")"; } #endif inline bool special() const { return m_special; } inline const_metadata_reference get_metadata() const { return m_metadata; } inline metadata_reference get_metadata() { return m_metadata; } value_type m_value; bool m_special; node_pointer m_p_left; node_pointer m_p_right; node_pointer m_p_parent; metadata_type m_metadata; }; template struct splay_tree_node_ { public: typedef Value_Type value_type; typedef null_node_metadata metadata_type; typedef typename Allocator::template rebind< splay_tree_node_ >::other::pointer node_pointer; inline bool special() const { return m_special; } #ifdef PB_DS_BIN_SEARCH_TREE_TRACE_ void trace() const { std::cout << PB_DS_V2F(m_value); } #endif node_pointer m_p_left; node_pointer m_p_right; node_pointer m_p_parent; value_type m_value; bool m_special; }; } // namespace detail } // namespace __gnu_pbds #endif // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 find_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { node_pointer p_found = find_imp(r_key); if (p_found != base_type::m_p_head) splay(p_found); return point_iterator(p_found); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::const_point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { const node_pointer p_found = find_imp(r_key); if (p_found != base_type::m_p_head) const_cast(this)->splay(p_found); return point_iterator(p_found); } PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: find_imp(const_key_reference r_key) { _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) node_pointer p_nd = base_type::m_p_head->m_p_parent; while (p_nd != NULL) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) { if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) return p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; return base_type::m_p_head; } PB_DS_CLASS_T_DEC inline const typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: find_imp(const_key_reference r_key) const { _GLIBCXX_DEBUG_ONLY(assert_valid();) node_pointer p_nd = base_type::m_p_head->m_p_parent; while (p_nd != NULL) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) { if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) return p_nd; p_nd = p_nd->m_p_left; } else p_nd = p_nd->m_p_right; return base_type::m_p_head; } // -*- C++ -*- // Copyright (C) 2005, 2006 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 2, 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. // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING. If not, write to // the Free Software Foundation, 59 Temple Place - Suite 330, Boston, // MA 02111-1307, USA. // As a special exception, you may use this file as part of a free // software library without restriction. Specifically, if other files // instantiate templates or use macros or inline functions from this // file, or you compile this file and link it with other files to // produce an executable, this file does not by itself cause the // resulting executable to be covered by the GNU General Public // License. This exception does not however invalidate any other // reasons why the executable file might be covered by the GNU General // Public License. // 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 constructors_destructor_fn_imps.hpp * Contains an implementation class for splay_tree_. */ PB_DS_CLASS_T_DEC template void PB_DS_CLASS_C_DEC:: copy_from_range(It first_it, It last_it) { while (first_it != last_it) insert(*(first_it++)); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME() { initialize(); _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : base_type(r_cmp_fn) { initialize(); _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : base_type(r_cmp_fn, r_node_update) { initialize(); _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : base_type(other) { initialize(); _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { _GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();) base_type::swap(