tl.lin.data.pair
Class PairOfIntFloat

java.lang.Object
  extended by tl.lin.data.pair.PairOfIntFloat
All Implemented Interfaces:
Comparable<PairOfIntFloat>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<PairOfIntFloat>

public class PairOfIntFloat
extends Object
implements org.apache.hadoop.io.WritableComparable<PairOfIntFloat>

WritableComparable representing a pair of an int and long. The elements in the pair are referred to as the left and right elements. The natural sort order is: first by the left element, and then by the right element.


Nested Class Summary
static class PairOfIntFloat.Comparator
          Comparator optimized for PairOfIntFloat.
 
Constructor Summary
PairOfIntFloat()
          Creates a pair.
PairOfIntFloat(int left, float right)
          Creates a pair.
 
Method Summary
 PairOfIntFloat clone()
          Clones this object.
 int compareTo(PairOfIntFloat pair)
          Defines a natural sort order for pairs.
 boolean equals(Object obj)
          Checks two pairs for equality.
 int getKey()
          Returns the key (left element).
 int getLeftElement()
          Returns the left element.
 float getRightElement()
          Returns the right element.
 float getValue()
          Returns the value (right element).
 int hashCode()
          Returns a hash code value for the pair.
 void readFields(DataInput in)
          Deserializes this pair.
 void set(int left, float right)
          Sets the right and left elements of this pair.
 String toString()
          Generates human-readable String representation of this pair.
 void write(DataOutput out)
          Serializes this pair.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PairOfIntFloat

public PairOfIntFloat()
Creates a pair.


PairOfIntFloat

public PairOfIntFloat(int left,
                      float right)
Creates a pair.

Parameters:
left - the left element
right - the right element
Method Detail

readFields

public void readFields(DataInput in)
                throws IOException
Deserializes this pair.

Specified by:
readFields in interface org.apache.hadoop.io.Writable
Parameters:
in - source for raw byte representation
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Serializes this pair.

Specified by:
write in interface org.apache.hadoop.io.Writable
Parameters:
out - where to write the raw byte representation
Throws:
IOException

getLeftElement

public int getLeftElement()
Returns the left element.

Returns:
the left element

getRightElement

public float getRightElement()
Returns the right element.

Returns:
the right element

getKey

public int getKey()
Returns the key (left element).

Returns:
the key

getValue

public float getValue()
Returns the value (right element).

Returns:
the value

set

public void set(int left,
                float right)
Sets the right and left elements of this pair.

Parameters:
left - the left element
right - the right element

equals

public boolean equals(Object obj)
Checks two pairs for equality.

Overrides:
equals in class Object
Parameters:
obj - object for comparison
Returns:
true if obj is equal to this object, false otherwise

compareTo

public int compareTo(PairOfIntFloat pair)
Defines a natural sort order for pairs. Pairs are sorted first by the left element, and then by the right element.

Specified by:
compareTo in interface Comparable<PairOfIntFloat>
Returns:
a value less than zero, a value greater than zero, or zero if this pair should be sorted before, sorted after, or is equal to obj.

hashCode

public int hashCode()
Returns a hash code value for the pair.

Overrides:
hashCode in class Object
Returns:
hash code for the pair

toString

public String toString()
Generates human-readable String representation of this pair.

Overrides:
toString in class Object
Returns:
human-readable String representation of this pair

clone

public PairOfIntFloat clone()
Clones this object.

Overrides:
clone in class Object
Returns:
clone of this object


Copyright © 2013. All Rights Reserved.