### IPair

  The IPair class provides generic ordered pairs of coordinates. The class serves as the base for the following specific ordered-pair classes:

  - IPoint
  - ISize
  - IRange

  This class provides basic utilities to get and set the two coordinate values. In addition, it provides a full set of comparison and mathematical operators to manipulate ordered pairs.

### IPair - Member Functions and Data by Group

### Constructors & Destructor

You can construct, copy, and assign objects of this class. This class uses the compiler-generated copy constructor and assignment operator to copy and assign IPair objects.

IPair
  Construct and destruct IPair objects.

  Overload 1

      public:
      IPair(Coord coord1, Coord coord2)

  Construct from two coordinate values.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 2

      public:
      IPair()

  Default constructor, sets both values to zero.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 3

      public:
      IPair(Coord init)

  Construct a pair object from a single coordinate, which is used for both pair values.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Comparison Operators

Use these members to compare one IPair object to another.

operator !=

      public:
      bool operator !=(const IPair& aPair) const

  True if either coordinate differs.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

operator <

      public:
      bool operator <(const IPair& aPair) const

  True if both coordinates are less than those of the specified aPair.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

operator <=

      public:
      bool operator <=(const IPair& aPair) const

  True if both coordinates are less than or equal.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

operator ==

      public:
      bool operator ==(const IPair& aPair) const

  True if both coordinates match those of the specified aPair.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

operator >

      public:
      bool operator >(const IPair& aPair) const

  True if both coordinates are greater than those of the specified aPair.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

operator >=

      public:
      bool operator >=(const IPair& aPair) const

  True if both coordinates are greater than or equal.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Conversions

Use these members to return an IPair object in a different form.

asDebugInfo

      public:
      IString asDebugInfo() const

  Converts the ordered pair to an IString containing a diagnostic representation of the object.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

asString

      public:
      IString asString() const

  Converts the ordered pair (a, b) to an IString( "(a, b)" ).

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

operator -

      public:
      IPair operator -() const

  Returns an ordered pair whose coordinates are the difference between the corresponding coordinates of pair1 and pair2.

  When you use the unary format, it returns an ordered pair with negated coordinates.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Coordinates

Use these members to query and change the ordered pair of integers in an IPair object.

coord1

      public:
      Coord coord1() const

  Obtains the value of the first coordinate.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

coord2

      public:
      Coord coord2() const

  Obtains the value of the second coordinate.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

setCoord1

      public:
      IPair& setCoord1(Coord coord1)

  Sets the value of the first coordinate.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

setCoord2

      public:
      IPair& setCoord2(Coord coord2)

  Sets the value of the second coordinate.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Manipulation

Use these members to alter the coordinate values of an IPair object. This includes both member and nonmember arithmetic operators and members to scale the value of an IPair object.

operator %=

  Replaces the coordinates with the remainder when divided by those of the following specified parameters:

  aPair
    The library performs the remainder function between the corresponding coordinates, coord1 with coord1 of aPair and coord2 with coord2.
  divisor
    The library performs the remainder function between each coordinate and the divisor.

  Overload 1

      public:
      IPair& operator %=(long divisor)

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 2

      public:
      IPair& operator %=(const IPair& aPair)

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

operator *=

  Multiplies the coordinates by those of the specified parameter:

  aPair
    The library performs the product function between the corresponding coordinates, coord1 with coord1 of aPair and coord2 with coord2.
  multiplier
    The library performs the product function between each coordinate and the multiplier.

  Overload 1

      public:
      IPair& operator *=(const IPair& aPair)

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 2

      public:
      IPair& operator *=(double multiplier)

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

operator +=

      public:
      IPair& operator +=(const IPair& aPair)

  Adds the coordinates of the specified aPair to the coordinates of an ordered pair.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

operator -=

      public:
      IPair& operator -=(const IPair& aPair)

  Subtracts the coordinates specified in aPair from the IPair coordinates.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

operator /=

  Divides the coordinates by those of the second specified parameter:

  aPair
    The library performs the quotient function between the corresponding coordinates, coord1 with coord1 of aPair and coord2 with coord2.
  divisor
    The library performs the product function between each coordinate and the divisor.

  Overload 1

      public:
      IPair& operator /=(double divisor)

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

  Overload 2

      public:
      IPair& operator /=(const IPair& aPair)

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

scaleBy

      public:
      IPair& scaleBy(double xFactor, double yFactor)

  Scales the X-coordinate by xFactor; the Y-coordinate by yFactor.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

scaledBy

      public:
      IPair scaledBy(double xFactor, double yFactor) const

  Same as IPair::scaleBy, but returns a new IPair, leaving the original unmodified.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Minimum and Maximum

Use these members to determine the smaller or larger of two IPair objects.

maximum

      public:
      IPair maximum(const IPair& aPair) const

  Returns an ordered pair whose coordinates are the maximum of the corresponding coordinates of the IPair and the specified IPair.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

minimum

      public:
      IPair minimum(const IPair& aPair) const

  Returns an ordered pair whose coordinates are the minimum of the corresponding coordinates of the IPair and the specified IPair.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Miscellaneous

These members are additional, unrelated members of the IPair class.

distanceFrom

      public:
      double distanceFrom(const IPair& aPair) const

  Returns the distance from some other ordered pair.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

dotProduct

      public:
      long dotProduct(const IPair& aPair) const

  Returns the dot product with another ordered pair.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

transpose

      public:
      IPair& transpose()

  Swaps the coordinates of the ordered pair. The friend version of this function returns a new pair with transposed coordinates.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### IPair - Type Definitions

Coord

      typedef long Coord

  Type of the coordinate values (long integer).

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### IPair - Associated Globals

operator %

      IPair operator %(const IPair& aPair1, long divisor)

  Returns an ordered pair whose coordinates are the remainder of the corresponding coordinates of the IPair (aPair1) and the divisor.

operator %

      IPair operator %(const IPair& pair1, const IPair& pair2)

  Returns an ordered pair whose coordinates are the remainder of the corresponding coordinates of pair1 and pair2.

operator *

      IPair operator *(const IPair& pair1, const IPair& pair2)

  Returns an ordered pair whose coordinates are the product of pair1 and pair2.

  The library performs the product function between the corresponding coordinates: coord1 of pair1 with coord1 of pair2 and coord2 with coord2.

operator *

      IPair operator *(const IPair& pair1, double multiplier)

  Returns an ordered pair whose coordinates are the product of pair1 and multiplier.

  The library performs the product function between each coordinate of pair1 and the multiplier.

operator +

      IPair operator +(const IPair& pair1, const IPair& pair2)

  Returns an ordered pair whose coordinates are the sums of the corresponding coordinates of pair1 and pair2.

operator -

      IPair operator -(const IPair& pair1, const IPair& pair2)

  Returns an ordered pair whose coordinates are the difference between the corresponding coordinates of pair1 and pair2.

  When you use the unary format, it returns an ordered pair with negated coordinates.

operator /

      IPair operator /(const IPair& pair1, double divisor)

  Returns an ordered pair whose coordinates are the quotient of the corresponding coordinates of pair1 and divisor

  The library performs the quotient function between each coordinate of pair1 and the divisor.

operator /

      IPair operator /(const IPair& pair1, const IPair& pair2)

  Returns an ordered pair whose coordinates are the quotient of the corresponding coordinates of pair1 and pair2 specified parameter:

  The library performs the quotient function between the corresponding coordinates: coord1 of pair1 with coord1 of pair2 and coord2 with coord2.

operator <<

      ostream& operator <<(ostream& aStream, const IPair& aRectangle)

  Writes ordered pairs to ostreams in the conventional manner.

transpose

      IPair transpose(const IPair& aPair)

  Swaps the coordinates of the ordered pair. The friend version of this function returns a new pair with transposed coordinates.

### IPair - Inherited Member Functions and Data

#### Inherited Public Functions

  - None

#### Inherited Public Data

  - None

#### Inherited Protected Functions

  - None

#### Inherited Protected Data

  - None