libstdc++
left_child_next_sibling_heap_/point_const_iterator.hpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the terms
00007 // of the GNU General Public License as published by the Free Software
00008 // Foundation; either version 3, or (at your option) any later
00009 // version.
00010 
00011 // This library is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
00026 
00027 // Permission to use, copy, modify, sell, and distribute this software
00028 // is hereby granted without fee, provided that the above copyright
00029 // notice appears in all copies, and that both that copyright notice
00030 // and this permission notice appear in supporting documentation. None
00031 // of the above authors, nor IBM Haifa Research Laboratories, make any
00032 // representation about the suitability of this software for any
00033 // purpose. It is provided "as is" without express or implied
00034 // warranty.
00035 
00036 /**
00037  * @file left_child_next_sibling_heap_/point_const_iterator.hpp
00038  * Contains an iterator class returned by the table's const find and insert
00039  * methods.
00040  */
00041 
00042 #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP
00043 #define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP
00044 
00045 #include <ext/pb_ds/tag_and_trait.hpp>
00046 #include <debug/debug.h>
00047 
00048 namespace __gnu_pbds
00049 {
00050   namespace detail
00051   {
00052 
00053 #define PB_DS_CLASS_T_DEC           \
00054     template<typename Node, typename _Alloc>
00055 
00056 #define PB_DS_CLASS_C_DEC \
00057     left_child_next_sibling_heap_node_point_const_iterator_<Node, _Alloc>
00058 
00059     /// Const point-type iterator.
00060     template<typename Node, typename _Alloc>
00061     class left_child_next_sibling_heap_node_point_const_iterator_
00062     {
00063     protected:
00064       typedef typename _Alloc::template rebind<Node>::other::pointer node_pointer;
00065 
00066     public:
00067       /// Category.
00068       typedef trivial_iterator_tag iterator_category;
00069 
00070       /// Difference type.
00071       typedef trivial_iterator_difference_type difference_type;
00072 
00073       /// Iterator's value type.
00074       typedef typename Node::value_type value_type;
00075 
00076       /// Iterator's pointer type.
00077       typedef
00078       typename _Alloc::template rebind<
00079     value_type>::other::pointer
00080       pointer;
00081 
00082       /// Iterator's const pointer type.
00083       typedef
00084       typename _Alloc::template rebind<
00085     value_type>::other::const_pointer
00086       const_pointer;
00087 
00088       /// Iterator's reference type.
00089       typedef
00090       typename _Alloc::template rebind<
00091     value_type>::other::reference
00092       reference;
00093 
00094       /// Iterator's const reference type.
00095       typedef
00096       typename _Alloc::template rebind<
00097     value_type>::other::const_reference
00098       const_reference;
00099 
00100       inline
00101       left_child_next_sibling_heap_node_point_const_iterator_(node_pointer p_nd) : m_p_nd(p_nd)
00102       { }
00103 
00104       /// Default constructor.
00105       inline
00106       left_child_next_sibling_heap_node_point_const_iterator_() : m_p_nd(0)
00107       { }
00108 
00109       /// Copy constructor.
00110       inline
00111       left_child_next_sibling_heap_node_point_const_iterator_(const PB_DS_CLASS_C_DEC& other) : m_p_nd(other.m_p_nd)
00112       { }
00113 
00114       /// Access.
00115       const_pointer
00116       operator->() const
00117       {
00118     _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
00119     return &m_p_nd->m_value;
00120       }
00121 
00122       /// Access.
00123       const_reference
00124       operator*() const
00125       {
00126     _GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
00127     return m_p_nd->m_value;
00128       }
00129 
00130       /// Compares content to a different iterator object.
00131       bool
00132       operator==(const PB_DS_CLASS_C_DEC& other) const
00133       { return m_p_nd == other.m_p_nd; }
00134 
00135       /// Compares content (negatively) to a different iterator object.
00136       bool
00137       operator!=(const PB_DS_CLASS_C_DEC& other) const
00138       { return m_p_nd != other.m_p_nd; }
00139 
00140       node_pointer m_p_nd;
00141     };
00142 
00143 #undef PB_DS_CLASS_T_DEC
00144 #undef PB_DS_CLASS_C_DEC
00145 
00146   } // namespace detail
00147 } // namespace __gnu_pbds
00148 
00149 #endif