]> gcc.gnu.org Git - gcc.git/blame - libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp
Update copyright years.
[gcc.git] / libstdc++-v3 / include / ext / pb_ds / detail / bin_search_tree_ / find_fn_imps.hpp
CommitLineData
4569a895
AT
1// -*- C++ -*-
2
5624e564 3// Copyright (C) 2005-2015 Free Software Foundation, Inc.
4569a895
AT
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
748086b7 8// Foundation; either version 3, or (at your option) any later
4569a895
AT
9// version.
10
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.
15
748086b7
JJ
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.
4569a895 19
748086b7
JJ
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/>.
4569a895
AT
24
25// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
26
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.
35
36/**
a345e45d 37 * @file bin_search_tree_/find_fn_imps.hpp
4569a895
AT
38 * Contains an implementation class for bin_search_tree_.
39 */
40
41PB_DS_CLASS_T_DEC
a345e45d 42inline typename PB_DS_CLASS_C_DEC::point_const_iterator
4569a895 43PB_DS_CLASS_C_DEC::
a345e45d 44lower_bound(key_const_reference r_key) const
4569a895
AT
45{
46 node_pointer p_pot = m_p_head;
47 node_pointer p_nd = m_p_head->m_p_parent;
48
8fc81078 49 while (p_nd != 0)
a345e45d 50 if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
4569a895
AT
51 p_nd = p_nd->m_p_right;
52 else
53 {
54 p_pot = p_nd;
4569a895
AT
55 p_nd = p_nd->m_p_left;
56 }
a345e45d 57 return iterator(p_pot);
4569a895
AT
58}
59
60PB_DS_CLASS_T_DEC
61inline typename PB_DS_CLASS_C_DEC::point_iterator
62PB_DS_CLASS_C_DEC::
a345e45d 63lower_bound(key_const_reference r_key)
4569a895
AT
64{
65 node_pointer p_pot = m_p_head;
66 node_pointer p_nd = m_p_head->m_p_parent;
67
8fc81078 68 while (p_nd != 0)
a345e45d 69 if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
4569a895
AT
70 p_nd = p_nd->m_p_right;
71 else
72 {
73 p_pot = p_nd;
4569a895
AT
74 p_nd = p_nd->m_p_left;
75 }
a345e45d 76 return iterator(p_pot);
4569a895
AT
77}
78
79PB_DS_CLASS_T_DEC
a345e45d 80inline typename PB_DS_CLASS_C_DEC::point_const_iterator
4569a895 81PB_DS_CLASS_C_DEC::
a345e45d 82upper_bound(key_const_reference r_key) const
4569a895
AT
83{
84 node_pointer p_pot = m_p_head;
85 node_pointer p_nd = m_p_head->m_p_parent;
86
8fc81078 87 while (p_nd != 0)
a345e45d 88 if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
4569a895 89 {
a345e45d
BK
90 p_pot = p_nd;
91 p_nd = p_nd->m_p_left;
4569a895
AT
92 }
93 else
94 p_nd = p_nd->m_p_right;
a345e45d 95 return const_iterator(p_pot);
4569a895
AT
96}
97
98PB_DS_CLASS_T_DEC
99inline typename PB_DS_CLASS_C_DEC::point_iterator
100PB_DS_CLASS_C_DEC::
a345e45d 101upper_bound(key_const_reference r_key)
4569a895
AT
102{
103 node_pointer p_pot = m_p_head;
104 node_pointer p_nd = m_p_head->m_p_parent;
105
8fc81078 106 while (p_nd != 0)
a345e45d 107 if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
4569a895 108 {
a345e45d
BK
109 p_pot = p_nd;
110 p_nd = p_nd->m_p_left;
4569a895
AT
111 }
112 else
113 p_nd = p_nd->m_p_right;
a345e45d 114 return point_iterator(p_pot);
4569a895
AT
115}
116
117PB_DS_CLASS_T_DEC
118inline typename PB_DS_CLASS_C_DEC::point_iterator
119PB_DS_CLASS_C_DEC::
a345e45d 120find(key_const_reference r_key)
4569a895 121{
f5886803 122 PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
f5886803 123 node_pointer p_pot = m_p_head;
4569a895
AT
124 node_pointer p_nd = m_p_head->m_p_parent;
125
8fc81078 126 while (p_nd != 0)
4569a895
AT
127 if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
128 {
129 p_pot = p_nd;
4569a895
AT
130 p_nd = p_nd->m_p_left;
131 }
132 else
133 p_nd = p_nd->m_p_right;
134
a345e45d
BK
135 node_pointer ret = p_pot;
136 if (p_pot != m_p_head)
137 {
138 const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value));
139 if (__cmp)
140 ret = m_p_head;
141 }
142 return point_iterator(ret);
4569a895
AT
143}
144
145PB_DS_CLASS_T_DEC
a345e45d 146inline typename PB_DS_CLASS_C_DEC::point_const_iterator
4569a895 147PB_DS_CLASS_C_DEC::
a345e45d 148find(key_const_reference r_key) const
4569a895 149{
f5886803 150 PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
f5886803 151 node_pointer p_pot = m_p_head;
4569a895
AT
152 node_pointer p_nd = m_p_head->m_p_parent;
153
8fc81078 154 while (p_nd != 0)
4569a895
AT
155 if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
156 {
157 p_pot = p_nd;
4569a895
AT
158 p_nd = p_nd->m_p_left;
159 }
160 else
161 p_nd = p_nd->m_p_right;
162
a345e45d
BK
163 node_pointer ret = p_pot;
164 if (p_pot != m_p_head)
165 {
166 const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value));
167 if (__cmp)
168 ret = m_p_head;
169 }
170 return point_const_iterator(ret);
4569a895 171}
This page took 0.85897 seconds and 5 git commands to generate.