Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.utilities.pairs
Class Pair<FIRST,SECOND>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.pairs.Pair<FIRST,SECOND>
Type Parameters:
FIRST - first type
SECOND - second type
Direct Known Subclasses:
CPair, FCPair, MinMax

public class Pair<FIRST,SECOND>
extends Object

Generic SimplePair class. Does not implement any "special" interfaces such as Comparable, use CPair if you want comparable pairs.

Author:
Erich Schubert

Nested Class Summary
static class Pair.Compare<FIRST,SECOND>
          Compare two SimplePairs based on two comparators
static class Pair.CompareByFirst<FIRST,SECOND>
          Compare two SimplePairs based on a comparator for the first component.
static class Pair.CompareBySecond<FIRST,SECOND>
          Compare two SimplePairs based on a comparator for the second component.
static class Pair.CompareSwapped<FIRST,SECOND>
          Compare two SimplePairs based on two comparators, but by second component first.
 
Field Summary
 FIRST first
          First value in pair
 SECOND second
          Second value in pair
 
Constructor Summary
Pair(FIRST first, SECOND second)
          Initialize pair
 
Method Summary
 boolean equals(Object obj)
          Simple equals statement.
 FIRST getFirst()
          Getter for first
 SECOND getSecond()
          Getter for second element in pair
 int hashCode()
          Canonical hash function, mixing the two hash values.
static
<F,S> Pair<F,S>[]
newArray(int size)
          Create a new array of the given size (for generics)
 void setFirst(FIRST first)
          Setter for first
 void setSecond(SECOND second)
          Setter for second
 String toString()
          Canonical toString operator
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

first

public FIRST first
First value in pair


second

public SECOND second
Second value in pair

Constructor Detail

Pair

public Pair(FIRST first,
            SECOND second)
Initialize pair

Parameters:
first - first parameter
second - second parameter
Method Detail

toString

public String toString()
Canonical toString operator

Overrides:
toString in class Object

getFirst

public final FIRST getFirst()
Getter for first

Returns:
first element in pair

setFirst

public final void setFirst(FIRST first)
Setter for first

Parameters:
first - new value for first element

getSecond

public final SECOND getSecond()
Getter for second element in pair

Returns:
second element in pair

setSecond

public final void setSecond(SECOND second)
Setter for second

Parameters:
second - new value for second element

newArray

public static final <F,S> Pair<F,S>[] newArray(int size)
Create a new array of the given size (for generics)

Type Parameters:
F - First class
S - Second class
Parameters:
size - array size
Returns:
empty array of the new type.

equals

public boolean equals(Object obj)
Simple equals statement. This Pair equals another Object if they are identical or if the other Object is also a Pair and the first and second element of this Pair equal the first and second element, respectively, of the other Pair.

Overrides:
equals in class Object
Parameters:
obj - Object to compare to

hashCode

public final int hashCode()
Canonical hash function, mixing the two hash values.

Overrides:
hashCode in class Object

Release 0.2.1 (2009-07-13_1605)