111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// -*- C++ -*- 211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// Copyright (C) 2005-2014 Free Software Foundation, Inc. 411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// 511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// This file is part of the GNU ISO C++ Library. This library is free 611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// software; you can redistribute it and/or modify it under the terms 711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// of the GNU General Public License as published by the Free Software 811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// Foundation; either version 3, or (at your option) any later 911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// version. 1011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 1111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// This library is distributed in the hope that it will be useful, but 1211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// WITHOUT ANY WARRANTY; without even the implied warranty of 1311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// General Public License for more details. 1511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 1611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// Under Section 7 of GPL version 3, you are granted additional 1711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// permissions described in the GCC Runtime Library Exception, version 1811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// 3.1, as published by the Free Software Foundation. 1911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 2011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// You should have received a copy of the GNU General Public License and 2111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// a copy of the GCC Runtime Library Exception along with this program; 2211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 2311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// <http://www.gnu.org/licenses/>. 2411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 2511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. 2611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 2711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// Permission to use, copy, modify, sell, and distribute this software 2811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// is hereby granted without fee, provided that the above copyright 2911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// notice appears in all copies, and that both that copyright notice 3011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// and this permission notice appear in supporting documentation. None 3111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// of the above authors, nor IBM Haifa Research Laboratories, make any 3211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// representation about the suitability of this software for any 3311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// purpose. It is provided "as is" without express or implied 3411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// warranty. 3511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 3611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/** 3711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * @file list_update_map_/insert_fn_imps.hpp 3811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Contains implementations of lu_map_. 3911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */ 4011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 4111cd02dfb91661c65134cac258cf5924270e9d2Dan AlbertPB_DS_CLASS_T_DEC 4211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertinline std::pair< 4311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert typename PB_DS_CLASS_C_DEC::point_iterator, 4411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert bool> 4511cd02dfb91661c65134cac258cf5924270e9d2Dan AlbertPB_DS_CLASS_C_DEC:: 4611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertinsert(const_reference r_val) 4711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert{ 4811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert PB_DS_ASSERT_VALID((*this)) 4911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert entry_pointer p_l = find_imp(PB_DS_V2F(r_val)); 5011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 5111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert if (p_l != 0) 5211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert { 5311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val)) 5411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert return std::make_pair(point_iterator(&p_l->m_value), false); 5511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert } 5611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 5711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val)) 5811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 5911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert p_l = allocate_new_entry(r_val, traits_base::m_no_throw_copies_indicator); 6011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert p_l->m_p_next = m_p_l; 6111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert m_p_l = p_l; 6211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert PB_DS_ASSERT_VALID((*this)) 6311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert return std::make_pair(point_iterator(&p_l->m_value), true); 6411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} 6511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 6611cd02dfb91661c65134cac258cf5924270e9d2Dan AlbertPB_DS_CLASS_T_DEC 6711cd02dfb91661c65134cac258cf5924270e9d2Dan Albertinline typename PB_DS_CLASS_C_DEC::entry_pointer 6811cd02dfb91661c65134cac258cf5924270e9d2Dan AlbertPB_DS_CLASS_C_DEC:: 6911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertallocate_new_entry(const_reference r_val, false_type) 7011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert{ 7111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert entry_pointer p_l = s_entry_allocator.allocate(1); 7211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert cond_dealtor_t cond(p_l); 7311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert new (const_cast<void* >(static_cast<const void* >(&p_l->m_value))) 7411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert value_type(r_val); 7511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 7611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert cond.set_no_action(); 7711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) 7811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert init_entry_metadata(p_l, s_metadata_type_indicator); 7911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert return p_l; 8011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} 8111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 8211cd02dfb91661c65134cac258cf5924270e9d2Dan AlbertPB_DS_CLASS_T_DEC 8311cd02dfb91661c65134cac258cf5924270e9d2Dan Albertinline typename PB_DS_CLASS_C_DEC::entry_pointer 8411cd02dfb91661c65134cac258cf5924270e9d2Dan AlbertPB_DS_CLASS_C_DEC:: 8511cd02dfb91661c65134cac258cf5924270e9d2Dan Albertallocate_new_entry(const_reference r_val, true_type) 8611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert{ 8711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert entry_pointer p_l = s_entry_allocator.allocate(1); 8811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert new (&p_l->m_value) value_type(r_val); 8911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) 9011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert init_entry_metadata(p_l, s_metadata_type_indicator); 9111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert return p_l; 9211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} 9311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 9411cd02dfb91661c65134cac258cf5924270e9d2Dan AlbertPB_DS_CLASS_T_DEC 9511cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttemplate<typename Metadata> 9611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertinline void 9711cd02dfb91661c65134cac258cf5924270e9d2Dan AlbertPB_DS_CLASS_C_DEC:: 9811cd02dfb91661c65134cac258cf5924270e9d2Dan Albertinit_entry_metadata(entry_pointer p_l, type_to_type<Metadata>) 9911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert{ new (&p_l->m_update_metadata) Metadata(s_update_policy()); } 10011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 10111cd02dfb91661c65134cac258cf5924270e9d2Dan AlbertPB_DS_CLASS_T_DEC 10211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertinline void 10311cd02dfb91661c65134cac258cf5924270e9d2Dan AlbertPB_DS_CLASS_C_DEC:: 10411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertinit_entry_metadata(entry_pointer, type_to_type<null_type>) 10511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert{ } 10611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 107