3 // Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 3, or (at your option) any later
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
27 // Permission to use, copy, modify, sell, and distribute this software
28 // is hereby granted without fee, provided that the above copyright
29 // notice appears in all copies, and that both that copyright notice
30 // and this permission notice appear in supporting documentation. None
31 // of the above authors, nor IBM Haifa Research Laboratories, make any
32 // representation about the suitability of this software for any
33 // purpose. It is provided "as is" without express or implied
37 * @file find_fn_imps.hpp
38 * Contains an implementation class for bin_search_tree_.
42 inline typename
PB_DS_CLASS_C_DEC::const_point_iterator
44 lower_bound(const_key_reference r_key
) const
46 node_pointer p_pot
= m_p_head
;
47 node_pointer p_nd
= m_p_head
->m_p_parent
;
50 if (Cmp_Fn::operator()(
51 PB_DS_V2F(p_nd
->m_value
),
53 p_nd
= p_nd
->m_p_right
;
58 p_nd
= p_nd
->m_p_left
;
61 return (iterator(p_pot
));
65 inline typename
PB_DS_CLASS_C_DEC::point_iterator
67 lower_bound(const_key_reference r_key
)
69 node_pointer p_pot
= m_p_head
;
70 node_pointer p_nd
= m_p_head
->m_p_parent
;
73 if (Cmp_Fn::operator()(
74 PB_DS_V2F(p_nd
->m_value
),
76 p_nd
= p_nd
->m_p_right
;
81 p_nd
= p_nd
->m_p_left
;
84 return (iterator(p_pot
));
88 inline typename
PB_DS_CLASS_C_DEC::const_point_iterator
90 upper_bound(const_key_reference r_key
) const
92 node_pointer p_pot
= m_p_head
;
93 node_pointer p_nd
= m_p_head
->m_p_parent
;
96 if (Cmp_Fn::operator()(r_key
,
97 PB_DS_V2F(p_nd
->m_value
)))
101 p_nd
= p_nd
->m_p_left
;
104 p_nd
= p_nd
->m_p_right
;
106 return (const_iterator(p_pot
));
110 inline typename
PB_DS_CLASS_C_DEC::point_iterator
112 upper_bound(const_key_reference r_key
)
114 node_pointer p_pot
= m_p_head
;
115 node_pointer p_nd
= m_p_head
->m_p_parent
;
118 if (Cmp_Fn::operator()(r_key
,
119 PB_DS_V2F(p_nd
->m_value
)))
123 p_nd
= p_nd
->m_p_left
;
126 p_nd
= p_nd
->m_p_right
;
128 return (point_iterator(p_pot
));
132 inline typename
PB_DS_CLASS_C_DEC::point_iterator
134 find(const_key_reference r_key
)
136 _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
138 node_pointer p_pot
= m_p_head
;
139 node_pointer p_nd
= m_p_head
->m_p_parent
;
142 if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd
->m_value
), r_key
))
146 p_nd
= p_nd
->m_p_left
;
149 p_nd
= p_nd
->m_p_right
;
151 return point_iterator((p_pot
!= m_p_head
&& Cmp_Fn::operator()(
153 PB_DS_V2F(p_pot
->m_value
)))?
158 inline typename
PB_DS_CLASS_C_DEC::const_point_iterator
160 find(const_key_reference r_key
) const
162 _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
164 node_pointer p_pot
= m_p_head
;
165 node_pointer p_nd
= m_p_head
->m_p_parent
;
168 if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd
->m_value
), r_key
))
172 p_nd
= p_nd
->m_p_left
;
175 p_nd
= p_nd
->m_p_right
;
177 return const_point_iterator((p_pot
!= m_p_head
&& Cmp_Fn::operator()(
179 PB_DS_V2F(p_pot
->m_value
)))?