cds.util
Class PairInteger

java.lang.Object
  extended bycds.util.PairInteger
All Implemented Interfaces:
java.io.Serializable

public class PairInteger
extends java.lang.Object
implements java.io.Serializable

Manages a pair of integers. Very simple class, sometimes usefull when a method has to return two numbers (like beginning and end of a substring.

Version:
1.0 July 2003, 1.1 Jan 2004 (BB) ajout de la methode equals.
Author:
Marc Wenger/CDS
See Also:
Serialized Form

Field Summary
private  int a
           
private  int b
           
 
Constructor Summary
PairInteger(int a, int b)
          Constructor.
PairInteger(PairInteger p)
          Copy constructor.
 
Method Summary
 int distance()
          Computes the distance between first and second integer (second - first)
 boolean equals(java.lang.Object o)
          MOD-BB 21-01-04 Ajout de cette methode.
 int getFirst()
          Get the first integer
 int getSecond()
          Get the first integer
 void setFirst(int a)
          Sets the first integer.
 void setSecond(int b)
          Sets the second integer.
 void setValues(int a, int b)
          Sets the values to a pairInteger object
 void setValues(PairInteger p)
          Sets the values to a pairInteger object
 java.lang.String toString()
          Get the pair in a string as 'a,b'
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

a

private int a

b

private int b
Constructor Detail

PairInteger

public PairInteger(int a,
                   int b)
Constructor. There is no empty constructor that would allow to create a non initialized pair of integers.

Parameters:
a - first integer
b - second integer

PairInteger

public PairInteger(PairInteger p)
Copy constructor.

Parameters:
p - PairInteger object
Method Detail

setFirst

public final void setFirst(int a)
Sets the first integer. The value overrides the current one

Parameters:
a - first integer.

setSecond

public final void setSecond(int b)
Sets the second integer. The value overrides the current one

Parameters:
b - second integer

setValues

public final void setValues(int a,
                            int b)
Sets the values to a pairInteger object

Parameters:
a - first integer
b - second integer

setValues

public final void setValues(PairInteger p)
Sets the values to a pairInteger object

Parameters:
p - PairInteger object

getFirst

public final int getFirst()
Get the first integer

Returns:
the first integer of the pair

getSecond

public final int getSecond()
Get the first integer

Returns:
the first integer of the pair

toString

public java.lang.String toString()
Get the pair in a string as 'a,b'

Returns:
the string 'a,b'

distance

public int distance()
Computes the distance between first and second integer (second - first)

Returns:
the distance

equals

public boolean equals(java.lang.Object o)
MOD-BB 21-01-04 Ajout de cette methode. Test d'egalite de PairInteger.

Parameters:
o - Objet a comparer.
Returns:
Vrai si o est identique a this, faux sinon.