src/lemon/xy.h
changeset 1398 2f21cc34a245
parent 1391 5b46af577b23
child 1420 e37cca875667
equal deleted inserted replaced
15:c03ebc13c474 16:d863bbbc95ef
   157 
   157 
   158   ///Read a plainvector from a stream
   158   ///Read a plainvector from a stream
   159   ///\relates xy
   159   ///\relates xy
   160   ///
   160   ///
   161   template<typename T>
   161   template<typename T>
   162   inline
   162   inline std::istream& operator>>(std::istream &is, xy<T> &z) {
   163   std::istream& operator>>(std::istream &is, xy<T> &z)
   163     char c;
   164   {
   164     if (is >> c) {
   165 
   165       if (c != '(') is.putback(c);
   166     is >> z.x >> z.y;
   166     } else {
       
   167       is.clear();
       
   168     }
       
   169     if (!(is >> z.x)) return is;
       
   170     if (is >> c) {
       
   171       if (c != ',') is.putback(c);
       
   172     } else {
       
   173       is.clear();
       
   174     }
       
   175     if (!(is >> z.y)) return is;
       
   176     if (is >> c) {
       
   177       if (c != ')') is.putback(c);
       
   178     } else {
       
   179       is.clear();
       
   180     }
   167     return is;
   181     return is;
   168   }
   182   }
   169 
   183 
   170   ///Write a plainvector to a stream
   184   ///Write a plainvector to a stream
   171 
   185 
   172   ///Write a plainvector to a stream
   186   ///Write a plainvector to a stream
   173   ///\relates xy
   187   ///\relates xy
   174   ///
   188   ///
   175   template<typename T>
   189   template<typename T>
   176   inline
   190   inline std::ostream& operator<<(std::ostream &os, const xy<T>& z)
   177   std::ostream& operator<<(std::ostream &os, xy<T> z)
       
   178   {
   191   {
   179     os << "(" << z.x << ", " << z.y << ")";
   192     os << "(" << z.x << ", " << z.y << ")";
   180     return os;
   193     return os;
   181   }
   194   }
   182 
   195