COIN-OR::LEMON - Graph Library

Changeset 240:4a1d2e642552 in lemon-0.x for src/work/athos/xy


Ignore:
Timestamp:
03/23/04 18:28:47 (20 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@338
Message:

Elkészült a boundingbox osztály (boundingbox.h) és hozzá a tesztprogi.

Location:
src/work/athos/xy
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/work/athos/xy/xy.cc

    r207 r240  
    66{
    77
    8         cout << "Még egy skalárt is kérek (szépen)!" << endl;
     8        cout << "Kérek szépen egy egész számot!" << endl;
    99        int s;
    1010        cin >> s;
  • src/work/athos/xy/xy.h

    r237 r240  
    1313  template<typename T>
    1414    class xy {
    15     T _x,_y;
    1615
    1716    public:
     17
     18      T x,y;     
    1819     
    1920      ///Default constructor: both coordinates become 0
    20       xy() : _x(0), _y(0 ){ /*_x=_y=0;*/ }
     21      xy() : x(0), y(0) {}
    2122
    22       ///Constructing from coordinates
    23       xy(T a, T b) : _x(a), _x(b) { /*_x=a; _y=b;*/ }
     23      ///Constructing the instance from coordinates
     24      xy(T a, T b) : x(a), y(a) { }
    2425
    25       ///Gives back the x coordinate
    26       T x(){
    27         return _x;
    28       };
    29 
    30       ///Gives back the y coordinate
    31       T y(){
    32         return _y;
    33       };
    3426
    3527      ///Gives back the square of the norm of the vector
    3628      T normSquare(){
    37         return _x*_x+_y*_y;
     29        return x*x+y*y;
    3830      };
    3931 
    4032      ///Increments the left hand side by u
    4133      xy<T>& operator +=(const xy<T>& u){
    42         _x += u._x;
    43         _y += u._y;
     34        x += u.x;
     35        y += u.y;
    4436        return *this;
    4537      };
     
    4739      ///Decrements the left hand side by u
    4840      xy<T>& operator -=(const xy<T>& u){
    49         _x -= u._x;
    50         _y -= u._y;
     41        x -= u.x;
     42        y -= u.y;
    5143        return *this;
    5244      };
     
    5446      ///Multiplying the left hand side with a scalar
    5547      xy<T>& operator *=(const T &u){
    56         _x *= u;
    57         _y *= u;
     48        x *= u;
     49        y *= u;
    5850        return *this;
    5951      };
     
    6153      ///Dividing the left hand side by a scalar
    6254      xy<T>& operator /=(const T &u){
    63         _x /= u;
    64         _y /= u;
     55        x /= u;
     56        y /= u;
    6557        return *this;
    6658      };
     
    6860      ///Returns the scalar product of two vectors
    6961      T operator *(const xy<T>& u){
    70         return _x*u._x+_y*u._y;
     62        return x*u.x+y*u.y;
    7163      };
    7264 
     
    9789      ///Testing equality
    9890      bool operator==(const xy<T> &u){
    99         return (_x==u._x) && (_y==u._y);
     91        return (x==u.x) && (y==u.y);
    10092      };
    10193
    10294      ///Testing inequality
    10395      bool operator!=(xy u){
    104         return  (_x!=u._x) || (_y!=u._y);
     96        return  (x!=u.x) || (y!=u.y);
    10597      };
    10698
     
    112104  std::istream& operator>>(std::istream &is, xy<T> &z)
    113105  {
    114     ///This is not the best solution here: I didn't know how to solve this with friend functions
    115     T a,b;
    116     is >> a >> b;
    117     xy<T> buf(a,b);
    118     z=buf;
     106
     107    is >> z.x >> z.y;
    119108    return is;
    120109  }
     
    125114  std::ostream& operator<<(std::ostream &os, xy<T> z)
    126115  {
    127     os << "(" << z.x() << ", " << z.y() << ")";
     116    os << "(" << z.x << ", " << z.y << ")";
    128117    return os;
    129118  }
Note: See TracChangeset for help on using the changeset viewer.