COIN-OR::LEMON - Graph Library

Changeset 2157:f9171bfc7ebb in lemon-0.x for lemon


Ignore:
Timestamp:
07/20/06 08:20:27 (18 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2872
Message:
  • Doc improvements
  • rot180() added to xy.h
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/xy.h

    r2006 r2157  
    4848  /// operators.
    4949  ///
     50  ///\note As you might have noticed, this class does not follow the
     51  ///\ref naming_conv "LEMON Coding Style" (it should be called \c Xy
     52  ///according to it). There is a stupid Hungarian proverb, "A kivétel
     53  ///erõsíti a szabályt" ("An exception
     54  ///reinforces a rule", which is
     55  ///actually a mistranslation of the Latin proverb "Exceptio probat regulam").
     56  ///This class is an example for that.
    5057  ///\author Attila Bernath
    5158  template<typename T>
     
    6471      xy() {}
    6572
    66       ///Constructing the instance from coordinates
     73      ///Construct an instance from coordinates
    6774      xy(T a, T b) : x(a), y(b) { }
    6875
     
    7178      template<class TT> xy(const xy<TT> &p) : x(p.x), y(p.y) {}
    7279
    73       ///Gives back the square of the norm of the vector
     80      ///Give back the square of the norm of the vector
    7481      T normSquare() const {
    7582        return x*x+y*y;
    7683      }
    7784 
    78       ///Increments the left hand side by u
     85      ///Increment the left hand side by u
    7986      xy<T>& operator +=(const xy<T>& u) {
    8087        x += u.x;
     
    8390      }
    8491 
    85       ///Decrements the left hand side by u
     92      ///Decrement the left hand side by u
    8693      xy<T>& operator -=(const xy<T>& u) {
    8794        x -= u.x;
     
    9097      }
    9198
    92       ///Multiplying the left hand side with a scalar
     99      ///Multiply the left hand side with a scalar
    93100      xy<T>& operator *=(const T &u) {
    94101        x *= u;
     
    97104      }
    98105
    99       ///Dividing the left hand side by a scalar
     106      ///Divide the left hand side by a scalar
    100107      xy<T>& operator /=(const T &u) {
    101108        x /= u;
     
    104111      }
    105112 
    106       ///Returns the scalar product of two vectors
     113      ///Return the scalar product of two vectors
    107114      T operator *(const xy<T>& u) const {
    108115        return x*u.x+y*u.y;
    109116      }
    110117 
    111       ///Returns the sum of two vectors
     118      ///Return the sum of two vectors
    112119      xy<T> operator+(const xy<T> &u) const {
    113120        xy<T> b=*this;
     
    115122      }
    116123
    117       ///Returns the neg of the vectors
     124      ///Return the neg of the vectors
    118125      xy<T> operator-() const {
    119126        xy<T> b=*this;
     
    122129      }
    123130
    124       ///Returns the difference of two vectors
     131      ///Return the difference of two vectors
    125132      xy<T> operator-(const xy<T> &u) const {
    126133        xy<T> b=*this;
     
    128135      }
    129136
    130       ///Returns a vector multiplied by a scalar
     137      ///Return a vector multiplied by a scalar
    131138      xy<T> operator*(const T &u) const {
    132139        xy<T> b=*this;
     
    134141      }
    135142
    136       ///Returns a vector divided by a scalar
     143      ///Return a vector divided by a scalar
    137144      xy<T> operator/(const T &u) const {
    138145        xy<T> b=*this;
     
    140147      }
    141148
    142       ///Testing equality
     149      ///Test equality
    143150      bool operator==(const xy<T> &u) const {
    144151        return (x==u.x) && (y==u.y);
    145152      }
    146153
    147       ///Testing inequality
     154      ///Test inequality
    148155      bool operator!=(xy u) const {
    149156        return  (x!=u.x) || (y!=u.y);
     
    152159    };
    153160
    154   ///Returns an xy
    155 
    156   ///Returns an xy
     161  ///Return an xy
     162
     163  ///Return an xy
    157164  ///\relates xy
    158165  template <typename T>
     
    161168  }
    162169
    163   ///Returns a vector multiplied by a scalar
    164 
    165   ///Returns a vector multiplied by a scalar
     170  ///Return a vector multiplied by a scalar
     171
     172  ///Return a vector multiplied by a scalar
    166173  ///\relates xy
    167174  template<typename T> xy<T> operator*(const T &u,const xy<T> &x) {
     
    220227  }
    221228
     229  ///Rotate by 180 degrees
     230
     231  ///Returns its parameter rotated by 180 degrees.
     232  ///\relates xy
     233  ///
     234  template<typename T>
     235  inline xy<T> rot180(const xy<T> &z)
     236  {
     237    return xy<T>(-z.x,-z.y);
     238  }
     239
    222240  ///Rotate by 270 degrees
    223241
     
    247265      BoundingBox() { _empty = true; }
    248266
    249       ///Constructing the instance from one point
     267      ///Construct an instance from one point
    250268      BoundingBox(xy<T> a) { bottom_left=top_right=a; _empty = false; }
    251269
     
    255273      }
    256274
    257       ///Makes the BoundingBox empty
     275      ///Make the BoundingBox empty
    258276      void clear() {
    259277        _empty=1;
    260278      }
    261279
    262       ///\brief Gives back the bottom left corner
    263       ///(if the bounding box is empty, then the return value is not defined)
     280      ///Give back the bottom left corner
     281
     282      ///Give back the bottom left corner.
     283      ///If the bounding box is empty, then the return value is not defined.
    264284      xy<T> bottomLeft() const {
    265285        return bottom_left;
    266286      }
    267287
    268       ///\brief Sets the bottom left corner
    269       ///(should only bee used for non-empty box)
     288      ///Set the bottom left corner
     289
     290      ///Set the bottom left corner.
     291      ///It should only bee used for non-empty box.
    270292      void bottomLeft(xy<T> p) {
    271293        bottom_left = p;
    272294      }
    273295
    274       ///\brief Gives back the top right corner
    275       ///(if the bounding box is empty, then the return value is not defined)
     296      ///Give back the top right corner
     297
     298      ///Give back the top right corner.
     299      ///If the bounding box is empty, then the return value is not defined.
    276300      xy<T> topRight() const {
    277301        return top_right;
    278302      }
    279303
    280       ///\brief Sets the top right corner
    281       ///(should only bee used for non-empty box)
     304      ///Set the top right corner
     305
     306      ///Set the top right corner.
     307      ///It should only bee used for non-empty box.
    282308      void topRight(xy<T> p) {
    283309        top_right = p;
    284310      }
    285311
    286       ///\brief Gives back the bottom right corner
    287       ///(if the bounding box is empty, then the return value is not defined)
     312      ///Give back the bottom right corner
     313
     314      ///Give back the bottom right corner.
     315      ///If the bounding box is empty, then the return value is not defined.
    288316      xy<T> bottomRight() const {
    289317        return xy<T>(top_right.x,bottom_left.y);
    290318      }
    291319
    292       ///\brief Sets the bottom right corner
    293       ///(should only bee used for non-empty box)
     320      ///Set the bottom right corner
     321
     322      ///Set the bottom right corner.
     323      ///It should only bee used for non-empty box.
    294324      void bottomRight(xy<T> p) {
    295325        top_right.x = p.x;
    296326        bottom_left.y = p.y;
    297327      }
    298 
    299       ///\brief Gives back the top left corner
    300       ///(if the bounding box is empty, then the return value is not defined)
     328 
     329      ///Give back the top left corner
     330
     331      ///Give back the top left corner.
     332      ///If the bounding box is empty, then the return value is not defined.
    301333      xy<T> topLeft() const {
    302334        return xy<T>(bottom_left.x,top_right.y);
    303335      }
    304336
    305       ///\brief Sets the top left corner
    306       ///(should only bee used for non-empty box)
     337      ///Set the top left corner
     338
     339      ///Set the top left corner.
     340      ///It should only bee used for non-empty box.
    307341      void topLeft(xy<T> p) {
    308342        top_right.y = p.y;
     
    310344      }
    311345
    312       ///\brief Gives back the bottom of the box
    313       ///(if the bounding box is empty, then the return value is not defined)
     346      ///Give back the bottom of the box
     347
     348      ///Give back the bottom of the box.
     349      ///If the bounding box is empty, then the return value is not defined.
    314350      T bottom() const {
    315351        return bottom_left.y;
    316352      }
    317353
    318       ///\brief Sets the bottom of the box
    319       ///(should only bee used for non-empty box)
     354      ///Set the bottom of the box
     355
     356      ///Set the bottom of the box.
     357      ///It should only bee used for non-empty box.
    320358      void bottom(T t) {
    321359        bottom_left.y = t;
    322360      }
    323361
    324       ///\brief Gives back the top of the box
    325       ///(if the bounding box is empty, then the return value is not defined)
     362      ///Give back the top of the box
     363
     364      ///Give back the top of the box.
     365      ///If the bounding box is empty, then the return value is not defined.
    326366      T top() const {
    327367        return top_right.y;
    328368      }
    329369
    330       ///\brief Sets the top of the box
    331       ///(should only bee used for non-empty box)
     370      ///Set the top of the box
     371
     372      ///Set the top of the box.
     373      ///It should only bee used for non-empty box.
    332374      void top(T t) {
    333375        top_right.y = t;
    334376      }
    335377
    336       ///\brief Gives back the left side of the box
    337       ///(if the bounding box is empty, then the return value is not defined)
     378      ///Give back the left side of the box
     379
     380      ///Give back the left side of the box.
     381      ///If the bounding box is empty, then the return value is not defined.
    338382      T left() const {
    339383        return bottom_left.x;
    340384      }
    341 
    342       ///\brief Sets the left side of the box
    343       ///(should only bee used for non-empty box)
     385 
     386      ///Set the left side of the box
     387
     388      ///Set the left side of the box.
     389      ///It should only bee used for non-empty box
    344390      void left(T t) {
    345391        bottom_left.x = t;
    346392      }
    347393
    348       ///\brief Gives back the right side of the box
    349       ///(if the bounding box is empty, then the return value is not defined)
     394      /// Give back the right side of the box
     395
     396      /// Give back the right side of the box.
     397      ///If the bounding box is empty, then the return value is not defined.
    350398      T right() const {
    351399        return top_right.x;
    352400      }
    353401
    354       ///\brief Sets the right side of the box
    355       ///(should only bee used for non-empty box)
     402      ///Set the right side of the box
     403
     404      ///Set the right side of the box.
     405      ///It should only bee used for non-empty box
    356406      void right(T t) {
    357407        top_right.x = t;
    358408      }
    359409
    360       ///\brief Gives back the height of the box
    361       ///(if the bounding box is empty, then the return value is not defined)
     410      ///Give back the height of the box
     411
     412      ///Give back the height of the box.
     413      ///If the bounding box is empty, then the return value is not defined.
    362414      T height() const {
    363415        return top_right.y-bottom_left.y;
    364416      }
    365417
    366       ///\brief Gives back the width of the box
    367       ///(if the bounding box is empty, then the return value is not defined)
     418      ///Give back the width of the box
     419
     420      ///Give back the width of the box.
     421      ///If the bounding box is empty, then the return value is not defined.
    368422      T width() const {
    369423        return top_right.x-bottom_left.x;
Note: See TracChangeset for help on using the changeset viewer.