Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.utilities.pairs
Class PairUtil

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.pairs.PairUtil

public final class PairUtil
extends Object

Utility functions for Pair classes.

Author:
Erich Schubert

Nested Class Summary
static class PairUtil.Compare<FIRST,SECOND>
          Compare two SimplePairs based on two comparators
static class PairUtil.CompareByFirst<FIRST,SECOND>
          Compare two SimplePairs based on a comparator for the first component.
static class PairUtil.CompareBySecond<FIRST,SECOND>
          Compare two SimplePairs based on a comparator for the second component.
static class PairUtil.CompareNatural<FIRST extends Comparable<? super FIRST>,SECOND extends Comparable<? super SECOND>>
          Class to do a "natural order" comparison on this class.
static class PairUtil.CompareNaturalFirst<FIRST extends Comparable<? super FIRST>,SECOND>
          Class to do a natural comparison on this class' first component.
static class PairUtil.CompareNaturalSecond<FIRST,SECOND extends Comparable<? super SECOND>>
          Class to do a natural comparison on this class' second component.
static class PairUtil.CompareNaturalSwapped<FIRST extends Comparable<? super FIRST>,SECOND extends Comparable<? super SECOND>>
          Class to do a canonical swapped comparison on this class.
static class PairUtil.CompareSwapped<FIRST,SECOND>
          Compare two SimplePairs based on two comparators, but by second component first.
 
Constructor Summary
PairUtil()
           
 
Method Summary
static
<FIRST extends Comparable<? super FIRST>,SECOND extends Comparable<? super SECOND>>
Comparator<Pair<FIRST,SECOND>>
comparator()
          Return a comparator for this pair, given that both components are already comparable.
static
<FIRST,SECOND>
Comparator<Pair<FIRST,SECOND>>
comparator(Comparator<FIRST> c1, Comparator<SECOND> c2)
          Return a derived comparator given a comparator for each component.
static
<FIRST extends Comparable<? super FIRST>,SECOND>
Comparator<Pair<FIRST,SECOND>>
comparatorFirst()
          Return a comparator by first component for this pair, given that the first component is already comparable.
static
<FIRST,SECOND>
Comparator<Pair<FIRST,SECOND>>
comparatorFirst(Comparator<FIRST> c1)
          Return a derived comparator by first component given a comparator for this component.
static
<FIRST,SECOND extends Comparable<? super SECOND>>
Comparator<Pair<FIRST,SECOND>>
comparatorSecond()
          Return a comparator by first component for this pair, given that the first component is already comparable.
static
<FIRST,SECOND>
Comparator<Pair<FIRST,SECOND>>
comparatorSecond(Comparator<SECOND> c2)
          Return a derived comparator by first component given a comparator for this component.
static
<FIRST extends Comparable<? super FIRST>,SECOND extends Comparable<? super SECOND>>
Comparator<Pair<FIRST,SECOND>>
comparatorSwapped()
          Return a component-swapped comparator for this pair, given that both components are already comparable.
static
<FIRST,SECOND>
Comparator<Pair<FIRST,SECOND>>
comparatorSwapped(Comparator<FIRST> c1, Comparator<SECOND> c2)
          Return a derived component-swapped comparator given a comparator for each component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PairUtil

public PairUtil()
Method Detail

comparator

public static <FIRST extends Comparable<? super FIRST>,SECOND extends Comparable<? super SECOND>> Comparator<Pair<FIRST,SECOND>> comparator()
Return a comparator for this pair, given that both components are already comparable. (So it could have been a CPair)

Type Parameters:
FIRST - First type
SECOND - Second type
Returns:
Comparator

comparator

public static <FIRST,SECOND> Comparator<Pair<FIRST,SECOND>> comparator(Comparator<FIRST> c1,
                                                                       Comparator<SECOND> c2)
Return a derived comparator given a comparator for each component.

Type Parameters:
FIRST - First type
SECOND - Second type
Parameters:
c1 - First comparator
c2 - Second comparator
Returns:
Comparator

comparatorFirst

public static <FIRST extends Comparable<? super FIRST>,SECOND> Comparator<Pair<FIRST,SECOND>> comparatorFirst()
Return a comparator by first component for this pair, given that the first component is already comparable. (So it could have been a FCPair)

Type Parameters:
FIRST - First type
SECOND - Second type
Returns:
Comparator

comparatorFirst

public static <FIRST,SECOND> Comparator<Pair<FIRST,SECOND>> comparatorFirst(Comparator<FIRST> c1)
Return a derived comparator by first component given a comparator for this component.

Type Parameters:
FIRST - First type
SECOND - Second type
Parameters:
c1 - Comparator for first
Returns:
Comparator

comparatorSecond

public static <FIRST,SECOND extends Comparable<? super SECOND>> Comparator<Pair<FIRST,SECOND>> comparatorSecond()
Return a comparator by first component for this pair, given that the first component is already comparable. (So it could have been a FCPair)

Type Parameters:
FIRST - First type
SECOND - Second type
Returns:
Comparator

comparatorSecond

public static <FIRST,SECOND> Comparator<Pair<FIRST,SECOND>> comparatorSecond(Comparator<SECOND> c2)
Return a derived comparator by first component given a comparator for this component.

Type Parameters:
FIRST - First type
SECOND - Second type
Parameters:
c2 - Comparator for second
Returns:
Comparator

comparatorSwapped

public static <FIRST extends Comparable<? super FIRST>,SECOND extends Comparable<? super SECOND>> Comparator<Pair<FIRST,SECOND>> comparatorSwapped()
Return a component-swapped comparator for this pair, given that both components are already comparable. (So it could have been a CPair)

Type Parameters:
FIRST - First type
SECOND - Second type
Returns:
Comparator

comparatorSwapped

public static <FIRST,SECOND> Comparator<Pair<FIRST,SECOND>> comparatorSwapped(Comparator<FIRST> c1,
                                                                              Comparator<SECOND> c2)
Return a derived component-swapped comparator given a comparator for each component.

Type Parameters:
FIRST - First type
SECOND - Second type
Parameters:
c1 - First comparator
c2 - Second comparator
Returns:
Comparator

Release 0.3 (2010-03-31_1612)