## org.apache.mahout.common
Class Pair<A,B>

    java.lang.Object
      org.apache.mahout.common.Pair<A,B>

All Implemented Interfaces:
  Serializable, Comparable<Pair<A,B>>

    public final class Pair<A,B>

extends Object
implements Comparable<Pair<A,B>>, Serializable

A simple (ordered) pair of two objects. Elements may be null.

See Also:
  Serialized Form

Constructor Summary
`Pair(A first, B second)`

Method Summary
`int` `compareTo(Pair<A,B> other)` Defines an ordering on pairs that sorts by first value's natural ordering, ascending, and then by second value's natural ordering.
`boolean` `equals(Object obj)`
`A` `getFirst()`
`B` `getSecond()`
`int` `hashCode()`

`static

`<A,B> Pair<A,B>`

`

`of(A a, B b)`

`Pair<B,A>` `swap()`
`String` `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Pair

    public Pair(A first,
                B second)

Method Detail

### getFirst

    public A getFirst()

### getSecond

    public B getSecond()

### swap

    public Pair<B,A> swap()

### of

    public static <A,B> Pair<A,B> of(A a,
                                     B b)

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### compareTo

    public int compareTo(Pair<A,B> other)

  Defines an ordering on pairs that sorts by first value's natural ordering, ascending, and then by second value's natural ordering.

  Specified by:
    `compareTo` in interface `Comparable<Pair<A,B>>`
  Throws:
    `ClassCastException` - if types are not actually `Comparable`

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.