3 // Copyright (C) 2005-2013 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 bin_search_tree_/find_fn_imps.hpp
38 * Contains an implementation class for bin_search_tree_.
42 inline typename PB_DS_CLASS_C_DEC::point_const_iterator
44 lower_bound(key_const_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()(PB_DS_V2F(p_nd->m_value), r_key))
51 p_nd = p_nd->m_p_right;
55 p_nd = p_nd->m_p_left;
57 return iterator(p_pot);
61 inline typename PB_DS_CLASS_C_DEC::point_iterator
63 lower_bound(key_const_reference r_key)
65 node_pointer p_pot = m_p_head;
66 node_pointer p_nd = m_p_head->m_p_parent;
69 if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
70 p_nd = p_nd->m_p_right;
74 p_nd = p_nd->m_p_left;
76 return iterator(p_pot);
80 inline typename PB_DS_CLASS_C_DEC::point_const_iterator
82 upper_bound(key_const_reference r_key) const
84 node_pointer p_pot = m_p_head;
85 node_pointer p_nd = m_p_head->m_p_parent;
88 if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
91 p_nd = p_nd->m_p_left;
94 p_nd = p_nd->m_p_right;
95 return const_iterator(p_pot);
99 inline typename PB_DS_CLASS_C_DEC::point_iterator
101 upper_bound(key_const_reference r_key)
103 node_pointer p_pot = m_p_head;
104 node_pointer p_nd = m_p_head->m_p_parent;
107 if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
110 p_nd = p_nd->m_p_left;
113 p_nd = p_nd->m_p_right;
114 return point_iterator(p_pot);
118 inline typename PB_DS_CLASS_C_DEC::point_iterator
120 find(key_const_reference r_key)
122 PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
123 node_pointer p_pot = m_p_head;
124 node_pointer p_nd = m_p_head->m_p_parent;
127 if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
130 p_nd = p_nd->m_p_left;
133 p_nd = p_nd->m_p_right;
135 node_pointer ret = p_pot;
136 if (p_pot != m_p_head)
138 const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value));
142 return point_iterator(ret);
146 inline typename PB_DS_CLASS_C_DEC::point_const_iterator
148 find(key_const_reference r_key) const
150 PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
151 node_pointer p_pot = m_p_head;
152 node_pointer p_nd = m_p_head->m_p_parent;
155 if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
158 p_nd = p_nd->m_p_left;
161 p_nd = p_nd->m_p_right;
163 node_pointer ret = p_pot;
164 if (p_pot != m_p_head)
166 const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value));
170 return point_const_iterator(ret);