• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

graph_iter.hh

00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #ifndef MLN_UTIL_INTERNAL_GRAPH_ITER_HH
00027 # define MLN_UTIL_INTERNAL_GRAPH_ITER_HH
00028 
00032 
00033 # include <mln/util/internal/graph_iter_base.hh>
00034 # include <mln/util/vertex.hh>
00035 # include <mln/util/edge.hh>
00036 
00037 
00038 
00039 namespace mln
00040 {
00041 
00042   namespace internal
00043   {
00044 
00046 
00047     template<typename G>
00048     class vertex_fwd_iterator
00049       : public graph_iter_base<G, util::vertex<G>, vertex_fwd_iterator<G> >
00050     {
00051       typedef graph_iter_base<G, util::vertex<G>, vertex_fwd_iterator<G> > super_;
00052 
00053       public:
00056         vertex_fwd_iterator();
00057         vertex_fwd_iterator(const G& g);
00059 
00060       protected:
00063         util::vertex_id_t start_id_() const;
00064 
00067         util::vertex_id_t next_id_() const;
00068 
00069         friend class graph_iter_base<G, util::vertex<G>, vertex_fwd_iterator<G> >;
00070     };
00071 
00072 
00074 
00075     template<typename G>
00076     class vertex_bkd_iterator
00077       : public graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> >
00078     {
00079       typedef graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> > super_;
00080 
00081       public:
00084         vertex_bkd_iterator();
00085         vertex_bkd_iterator(const G& g);
00087 
00088       protected:
00091         util::vertex_id_t start_id_() const;
00092 
00095         util::vertex_id_t next_id_() const;
00096 
00097         friend class graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> >;
00098     };
00099 
00100 
00102 
00103     template <typename G>
00104     class edge_fwd_iterator
00105       : public graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> >
00106     {
00107       typedef graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> > super_;
00108 
00109       public:
00112         edge_fwd_iterator();
00113         edge_fwd_iterator(const G& g);
00115 
00116       protected:
00119         util::edge_id_t start_id_() const;
00120 
00123         util::edge_id_t next_id_() const;
00124 
00125         friend class graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> >;
00126     };
00127 
00128 
00130 
00131     template <typename G>
00132     class edge_bkd_iterator
00133       : public graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> >
00134     {
00135       typedef graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> > super_;
00136 
00137       public:
00140         edge_bkd_iterator();
00141         edge_bkd_iterator(const G& g);
00143 
00144       protected:
00147         util::edge_id_t start_id_() const;
00148 
00151         util::edge_id_t next_id_() const;
00152 
00153         friend class graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> >;
00154     };
00155 
00156 
00157 
00158 
00159 # ifndef MLN_INCLUDE_ONLY
00160 
00161 
00162     /*--------------------`
00163     | vertex_fwd_iterator |
00164     \--------------------*/
00165 
00166     template <typename G>
00167     inline
00168     vertex_fwd_iterator<G>::vertex_fwd_iterator()
00169     {
00170     }
00171 
00172     template <typename G>
00173     inline
00174     vertex_fwd_iterator<G>::vertex_fwd_iterator(const G& g)
00175       : super_(g)
00176     {
00177     }
00178 
00179     template <typename G>
00180     inline
00181     util::vertex_id_t
00182     vertex_fwd_iterator<G>::start_id_() const
00183     {
00184       return 0;
00185     }
00186 
00187     template <typename G>
00188     inline
00189     util::vertex_id_t
00190     vertex_fwd_iterator<G>::next_id_() const
00191     {
00192       return this->p_.id().value() + 1;
00193     }
00194 
00195 
00196 
00197     /*--------------------`
00198     | vertex_bkd_iterator |
00199     \--------------------*/
00200 
00201     template <typename G>
00202     inline
00203     vertex_bkd_iterator<G>::vertex_bkd_iterator()
00204     {
00205     }
00206 
00207     template <typename G>
00208     inline
00209     vertex_bkd_iterator<G>::vertex_bkd_iterator(const G& g)
00210       : super_(g)
00211     {
00212     }
00213 
00214     template <typename G>
00215     inline
00216     util::vertex_id_t
00217     vertex_bkd_iterator<G>::start_id_() const
00218     {
00219       return this->p_.graph().v_nmax() - 1;
00220     }
00221 
00222     template <typename G>
00223     inline
00224     util::vertex_id_t
00225     vertex_bkd_iterator<G>::next_id_() const
00226     {
00227       return this->p_.id().value() - 1;
00228     }
00229 
00230 
00231 
00232     /*------------------`
00233     | edge_fwd_iterator |
00234     \------------------*/
00235 
00236     template <typename G>
00237     inline
00238     edge_fwd_iterator<G>::edge_fwd_iterator()
00239     {
00240     }
00241 
00242     template <typename G>
00243     inline
00244     edge_fwd_iterator<G>::edge_fwd_iterator(const G& g)
00245       : super_(g)
00246     {
00247     }
00248 
00249     template <typename G>
00250     inline
00251     util::edge_id_t
00252     edge_fwd_iterator<G>::start_id_() const
00253     {
00254       return 0;
00255     }
00256 
00257     template <typename G>
00258     inline
00259     util::edge_id_t
00260     edge_fwd_iterator<G>::next_id_() const
00261     {
00262       return this->p_.id().value() + 1;
00263     }
00264 
00265 
00266 
00267     /*------------------`
00268     | edge_bkd_iterator |
00269     \------------------*/
00270 
00271     template <typename G>
00272     inline
00273     edge_bkd_iterator<G>::edge_bkd_iterator()
00274     {
00275     }
00276 
00277     template <typename G>
00278     inline
00279     edge_bkd_iterator<G>::edge_bkd_iterator(const G& g)
00280       : super_(g)
00281     {
00282     }
00283 
00284     template <typename G>
00285     inline
00286     util::edge_id_t
00287     edge_bkd_iterator<G>::start_id_() const
00288     {
00289       return this->p_.graph().e_nmax() - 1;
00290     }
00291 
00292     template <typename G>
00293     inline
00294     util::edge_id_t
00295     edge_bkd_iterator<G>::next_id_() const
00296     {
00297       return this->p_.id().value() - 1;
00298     }
00299 
00300 # endif // ! MLN_INCLUDE_ONLY
00301 
00302   } // end of namespace mln::internal
00303 
00304 } // end of namespace mln
00305 
00306 
00307 #endif // ! MLN_UTIL_INTERNAL_GRAPH_ITER_HH

Generated on Tue Oct 4 2011 15:23:50 for Milena (Olena) by  doxygen 1.7.1