find_fn_imps.hpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
00031 
00032 // Permission to use, copy, modify, sell, and distribute this software
00033 // is hereby granted without fee, provided that the above copyright
00034 // notice appears in all copies, and that both that copyright notice and
00035 // this permission notice appear in supporting documentation. None of
00036 // the above authors, nor IBM Haifa Research Laboratories, make any
00037 // representation about the suitability of this software for any
00038 // purpose. It is provided "as is" without express or implied warranty.
00039 
00045 PB_ASSOC_CLASS_T_DEC
00046 inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator
00047 PB_ASSOC_CLASS_C_DEC::
00048 lower_bound(const_key_reference r_key) const
00049 {
00050   node_pointer p_pot = m_p_head;
00051   node_pointer p_nd = m_p_head->m_p_parent;
00052 
00053   while (p_nd != NULL)
00054     if (!Cmp_Fn::operator()(PB_ASSOC_V2F(p_nd->m_value), r_key))
00055       {
00056     p_pot = p_nd;
00057 
00058     p_nd = p_nd->m_p_left;
00059       }
00060     else
00061       p_nd = p_nd->m_p_right;
00062 
00063   return (iterator(p_pot));
00064 }
00065 
00066 PB_ASSOC_CLASS_T_DEC
00067 inline typename PB_ASSOC_CLASS_C_DEC::find_iterator
00068 PB_ASSOC_CLASS_C_DEC::
00069 lower_bound(const_key_reference r_key)
00070 {
00071   node_pointer p_pot = m_p_head;
00072   node_pointer p_nd = m_p_head->m_p_parent;
00073 
00074   while (p_nd != NULL)
00075     if (!Cmp_Fn::operator()(
00076                 PB_ASSOC_V2F(p_nd->m_value),
00077                 r_key))
00078       {
00079     p_pot = p_nd;
00080 
00081     p_nd = p_nd->m_p_left;
00082       }
00083     else
00084       p_nd = p_nd->m_p_right;
00085 
00086   return (iterator(p_pot));
00087 }
00088 
00089 PB_ASSOC_CLASS_T_DEC
00090 inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator
00091 PB_ASSOC_CLASS_C_DEC::
00092 upper_bound(const_key_reference r_key) const
00093 {
00094   node_pointer p_pot = m_p_head;
00095   node_pointer p_nd = m_p_head->m_p_parent;
00096 
00097   while (p_nd != NULL)
00098     if (Cmp_Fn::operator()(r_key,
00099                PB_ASSOC_V2F(p_nd->m_value)))
00100       {
00101     p_pot = p_nd,
00102 
00103       p_nd = p_nd->m_p_left;
00104       }
00105     else
00106       p_nd = p_nd->m_p_right;
00107 
00108   return (const_iterator(p_pot));
00109 }
00110 
00111 PB_ASSOC_CLASS_T_DEC
00112 inline typename PB_ASSOC_CLASS_C_DEC::find_iterator
00113 PB_ASSOC_CLASS_C_DEC::
00114 upper_bound(const_key_reference r_key)
00115 {
00116   node_pointer p_pot = m_p_head;
00117   node_pointer p_nd = m_p_head->m_p_parent;
00118 
00119   while (p_nd != NULL)
00120     if (Cmp_Fn::operator()(r_key,
00121                PB_ASSOC_V2F(p_nd->m_value)))
00122       {
00123     p_pot = p_nd,
00124 
00125       p_nd = p_nd->m_p_left;
00126       }
00127     else
00128       p_nd = p_nd->m_p_right;
00129 
00130   return (find_iterator(p_pot));
00131 }
00132 
00133 PB_ASSOC_CLASS_T_DEC
00134 inline typename PB_ASSOC_CLASS_C_DEC::find_iterator
00135 PB_ASSOC_CLASS_C_DEC::
00136 find(const_key_reference r_key)
00137 {
00138   PB_ASSOC_DBG_ONLY(assert_valid(true, false);)
00139 
00140     node_pointer p_pot = m_p_head;
00141   node_pointer p_nd = m_p_head->m_p_parent;
00142 
00143   while (p_nd != NULL)
00144     if (!Cmp_Fn::operator()(PB_ASSOC_V2F(p_nd->m_value), r_key))
00145       {
00146     p_pot = p_nd;
00147 
00148     p_nd = p_nd->m_p_left;
00149       }
00150     else
00151       p_nd = p_nd->m_p_right;
00152 
00153   return find_iterator((p_pot != m_p_head&&  Cmp_Fn::operator()(
00154                                 r_key,
00155                                 PB_ASSOC_V2F(p_pot->m_value)))?
00156                m_p_head : p_pot);
00157 }
00158 
00159 PB_ASSOC_CLASS_T_DEC
00160 inline typename PB_ASSOC_CLASS_C_DEC::const_find_iterator
00161 PB_ASSOC_CLASS_C_DEC::
00162 find(const_key_reference r_key) const
00163 {
00164   PB_ASSOC_DBG_ONLY(assert_valid(true, true);)
00165 
00166     node_pointer p_pot = m_p_head;
00167   node_pointer p_nd = m_p_head->m_p_parent;
00168 
00169   while (p_nd != NULL)
00170     if (!Cmp_Fn::operator()(PB_ASSOC_V2F(p_nd->m_value), r_key))
00171       {
00172     p_pot = p_nd;
00173 
00174     p_nd = p_nd->m_p_left;
00175       }
00176     else
00177       p_nd = p_nd->m_p_right;
00178 
00179   return const_find_iterator((p_pot != m_p_head&&  Cmp_Fn::operator()(
00180                                       r_key,
00181                                       PB_ASSOC_V2F(p_pot->m_value)))?
00182                  m_p_head : p_pot);
00183 }
00184 

Generated on Tue Feb 2 16:55:56 2010 for GNU C++ STL by  doxygen 1.4.7