3 // Copyright (C) 2005 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
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32 // Permission to use, copy, modify, sell, and distribute this software
33 // is hereby granted without fee, provided that the above copyright
34 // notice appears in all copies, and that both that copyright notice and
35 // this permission notice appear in supporting documentation. None of
36 // the above authors, nor IBM Haifa Research Laboratories, make any
37 // representation about the suitability of this software for any
38 // purpose. It is provided "as is" without express or implied warranty.
41 * @file find_iterators.hpp
42 * Contains an implementation class for bin_search_tree_.
45 #define PB_ASSOC_CONST_IT_C_DEC \
49 #define PB_ASSOC_CONST_ODIR_IT_C_DEC \
53 #define PB_ASSOC_IT_C_DEC \
57 #define PB_ASSOC_ODIR_IT_C_DEC \
61 template<bool Is_Forward_Iterator>
67 typedef std::bidirectional_iterator_tag iterator_category;
69 typedef typename Allocator::difference_type difference_type;
71 typedef mapped_value_type value_type;
73 typedef mapped_pointer pointer;
75 typedef const_mapped_pointer const_pointer;
77 typedef mapped_reference reference;
79 typedef const_mapped_reference const_reference;
84 const_it_(const node_pointer p_nd = NULL) : m_p_nd(const_cast<node_pointer>(p_nd))
88 const_it_(const PB_ASSOC_CONST_ODIR_IT_C_DEC&
91 : m_p_nd(r_other.m_p_nd)
95 PB_ASSOC_CONST_IT_C_DEC&
96 operator=(const PB_ASSOC_CONST_IT_C_DEC&
99 m_p_nd = r_other.m_p_nd;
105 PB_ASSOC_CONST_IT_C_DEC&
106 operator=(const PB_ASSOC_CONST_ODIR_IT_C_DEC&
109 m_p_nd = r_other.m_p_nd;
117 PB_ASSOC_DBG_ASSERT(m_p_nd != NULL);
119 return (&m_p_nd->m_value);
122 inline const_reference
125 PB_ASSOC_DBG_ASSERT(m_p_nd != NULL);
127 return (m_p_nd->m_value);
131 operator==(const PB_ASSOC_CONST_IT_C_DEC
134 return (m_p_nd == r_other.m_p_nd);
138 operator==(const PB_ASSOC_CONST_ODIR_IT_C_DEC
141 return (m_p_nd == r_other.m_p_nd);
145 operator!=(const PB_ASSOC_CONST_IT_C_DEC&
148 return (m_p_nd != r_other.m_p_nd);
152 operator!=(const PB_ASSOC_CONST_ODIR_IT_C_DEC&
155 return (m_p_nd != r_other.m_p_nd);
158 inline PB_ASSOC_CONST_IT_C_DEC&
161 PB_ASSOC_DBG_ASSERT(m_p_nd != NULL);
163 inc(int_to_type<Is_Forward_Iterator>());
168 inline PB_ASSOC_CONST_IT_C_DEC
171 PB_ASSOC_CONST_IT_C_DEC
179 inline PB_ASSOC_CONST_IT_C_DEC&
182 dec(int_to_type<Is_Forward_Iterator>());
187 inline PB_ASSOC_CONST_IT_C_DEC
190 PB_ASSOC_CONST_IT_C_DEC
200 inc(int_to_type<false>)
202 dec(int_to_type<true>());
206 inc(int_to_type<true>)
208 if (m_p_nd->m_p_right != NULL)
210 m_p_nd = m_p_nd->m_p_right;
212 while (m_p_nd->m_p_left != NULL)
213 m_p_nd = m_p_nd->m_p_left;
218 node_pointer p_y = m_p_nd->m_p_parent;
220 while (m_p_nd == p_y->m_p_right)
224 p_y = p_y->m_p_parent;
227 if (m_p_nd->m_p_right != p_y)
232 dec(int_to_type<false>)
234 inc(int_to_type<true>());
238 dec(int_to_type<true>)
240 if (m_p_nd->special_dec_check()&&
241 m_p_nd->m_p_parent->m_p_parent == m_p_nd)
243 m_p_nd = m_p_nd->m_p_right;
248 if (m_p_nd->m_p_left != NULL)
250 node_pointer p_y = m_p_nd->m_p_left;
252 while (p_y->m_p_right != NULL)
253 p_y = p_y->m_p_right;
260 node_pointer p_y = m_p_nd->m_p_parent;
262 while (m_p_nd == p_y->m_p_left)
266 p_y = p_y->m_p_parent;
270 * This seems to correct an apparent bug in the SGI STL
272 if (m_p_nd->m_p_left != p_y)
276 friend class PB_ASSOC_CLASS_C_DEC;
282 template<bool Is_Forward_Iterator>
284 public PB_ASSOC_CONST_IT_C_DEC
291 it_(const node_pointer p_nd = NULL) : PB_ASSOC_CONST_IT_C_DEC((node_pointer)p_nd)
295 it_(const PB_ASSOC_ODIR_IT_C_DEC&
298 : PB_ASSOC_CONST_IT_C_DEC(
304 operator=(const PB_ASSOC_IT_C_DEC&
307 my_base_it::m_p_nd = r_other.m_p_nd;
314 operator=(const PB_ASSOC_ODIR_IT_C_DEC&
317 my_base_it::m_p_nd = r_other.m_p_nd;
325 PB_ASSOC_DBG_ASSERT(my_base_it::m_p_nd != NULL);
327 return (&my_base_it::m_p_nd->m_value);
333 PB_ASSOC_DBG_ASSERT(my_base_it::m_p_nd != NULL);
335 return (my_base_it::m_p_nd->m_value);
338 inline PB_ASSOC_IT_C_DEC&
341 PB_ASSOC_CONST_IT_C_DEC::
347 inline PB_ASSOC_IT_C_DEC
351 ret_it(my_base_it::m_p_nd);
358 inline PB_ASSOC_IT_C_DEC&
361 PB_ASSOC_CONST_IT_C_DEC::
367 inline PB_ASSOC_IT_C_DEC
371 ret_it(my_base_it::m_p_nd);
379 typedef PB_ASSOC_CONST_IT_C_DEC my_base_it;
381 friend class PB_ASSOC_CLASS_C_DEC;
384 #undef PB_ASSOC_CONST_IT_C_DEC
386 #undef PB_ASSOC_CONST_ODIR_IT_C_DEC
388 #undef PB_ASSOC_IT_C_DEC
390 #undef PB_ASSOC_ODIR_IT_C_DEC