net.sourceforge.cilib.container
Class Pair<K extends Comparable<? super K>,V>

java.lang.Object
  extended by net.sourceforge.cilib.container.Pair<K,V>
Type Parameters:
K - The key value.
V - The Object to associate to the key.
All Implemented Interfaces:
Serializable, Comparable<Pair<K,V>>, Cloneable

public class Pair<K extends Comparable<? super K>,V>
extends Object
implements Comparable<Pair<K,V>>, Cloneable, Serializable

Simple structure to associate a key to a value.

Author:
Gary Pampara
See Also:
Serialized Form

Constructor Summary
Pair()
          Default constructor.
Pair(K key, V value)
          Construct a Pair with the given key and value.
Pair(Pair<K,V> copy)
          Copy constructor.
 
Method Summary
 int compareTo(Pair<K,V> o)
          
 boolean equals(Object obj)
          
 Pair<K,V> getClone()
          Create a cloned copy of the current object and return it.
 K getKey()
           
 V getValue()
           
 int hashCode()
          
 void setKey(K key)
           
 void setValue(V value)
           
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pair

public Pair()
Default constructor. Assigns both the key and the value to null.


Pair

public Pair(K key,
            V value)
Construct a Pair with the given key and value.

Parameters:
key - The key value to set.
value - The object to associate with this key.

Pair

public Pair(Pair<K,V> copy)
Copy constructor.

Parameters:
copy - The object to copy.
Method Detail

getClone

public Pair<K,V> getClone()
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Cloneable
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

getKey

public K getKey()
Returns:
Returns the key.

setKey

public void setKey(K key)
Parameters:
key - The key to set.

getValue

public V getValue()
Returns:
Returns the value.

setValue

public void setValue(V value)
Parameters:
value - The value to set.

compareTo

public int compareTo(Pair<K,V> o)

Specified by:
compareTo in interface Comparable<Pair<K extends Comparable<? super K>,V>>
Parameters:
o - The Pair to perform the comparison with.
Returns:
The result of the comparison.

toString

public String toString()

Overrides:
toString in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object


Copyright © 2009 CIRG. All Rights Reserved.