Update Copyright years for files modified in 2010.
[official-gcc.git] / libstdc++-v3 / include / ext / pb_ds / detail / bin_search_tree_ / find_fn_imps.hpp
blob082c7f0f79d0b3a9d191f4a2b79833bfacb83bb8
1 // -*- C++ -*-
3 // Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
4 //
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
9 // version.
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
34 // warranty.
36 /**
37 * @file find_fn_imps.hpp
38 * Contains an implementation class for bin_search_tree_.
41 PB_DS_CLASS_T_DEC
42 inline typename PB_DS_CLASS_C_DEC::const_point_iterator
43 PB_DS_CLASS_C_DEC::
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;
49 while (p_nd != 0)
50 if (Cmp_Fn::operator()(
51 PB_DS_V2F(p_nd->m_value),
52 r_key))
53 p_nd = p_nd->m_p_right;
54 else
56 p_pot = p_nd;
58 p_nd = p_nd->m_p_left;
61 return (iterator(p_pot));
64 PB_DS_CLASS_T_DEC
65 inline typename PB_DS_CLASS_C_DEC::point_iterator
66 PB_DS_CLASS_C_DEC::
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;
72 while (p_nd != 0)
73 if (Cmp_Fn::operator()(
74 PB_DS_V2F(p_nd->m_value),
75 r_key))
76 p_nd = p_nd->m_p_right;
77 else
79 p_pot = p_nd;
81 p_nd = p_nd->m_p_left;
84 return (iterator(p_pot));
87 PB_DS_CLASS_T_DEC
88 inline typename PB_DS_CLASS_C_DEC::const_point_iterator
89 PB_DS_CLASS_C_DEC::
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;
95 while (p_nd != 0)
96 if (Cmp_Fn::operator()(r_key,
97 PB_DS_V2F(p_nd->m_value)))
99 p_pot = p_nd,
101 p_nd = p_nd->m_p_left;
103 else
104 p_nd = p_nd->m_p_right;
106 return (const_iterator(p_pot));
109 PB_DS_CLASS_T_DEC
110 inline typename PB_DS_CLASS_C_DEC::point_iterator
111 PB_DS_CLASS_C_DEC::
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;
117 while (p_nd != 0)
118 if (Cmp_Fn::operator()(r_key,
119 PB_DS_V2F(p_nd->m_value)))
121 p_pot = p_nd,
123 p_nd = p_nd->m_p_left;
125 else
126 p_nd = p_nd->m_p_right;
128 return (point_iterator(p_pot));
131 PB_DS_CLASS_T_DEC
132 inline typename PB_DS_CLASS_C_DEC::point_iterator
133 PB_DS_CLASS_C_DEC::
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;
141 while (p_nd != 0)
142 if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
144 p_pot = p_nd;
146 p_nd = p_nd->m_p_left;
148 else
149 p_nd = p_nd->m_p_right;
151 return point_iterator((p_pot != m_p_head&& Cmp_Fn::operator()(
152 r_key,
153 PB_DS_V2F(p_pot->m_value)))?
154 m_p_head : p_pot);
157 PB_DS_CLASS_T_DEC
158 inline typename PB_DS_CLASS_C_DEC::const_point_iterator
159 PB_DS_CLASS_C_DEC::
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;
167 while (p_nd != 0)
168 if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
170 p_pot = p_nd;
172 p_nd = p_nd->m_p_left;
174 else
175 p_nd = p_nd->m_p_right;
177 return const_point_iterator((p_pot != m_p_head&& Cmp_Fn::operator()(
178 r_key,
179 PB_DS_V2F(p_pot->m_value)))?
180 m_p_head : p_pot);