目标:做一个tuple 存放pair 对象
例子:
比如我要存放的数据来自数据库,SELECT distinct host,platform FROM "Log_loginfo",host 和 platform 是一个pair 对象,用字符串串接麻烦又有提取回来失误的风险,用map本质上是key-value的关系而不是pair关系,因此,使用tuple来解决。
tuple.java
package j2seTest2;
import java.io.Serializable;
public class Tuple<L, R> implements Serializable {
private static final long serialVersionUID = 1L;
/** The left object. */
public L left;
/** The right object. */
public R right;
/** Construct a tuple with the specified two objects. */
public Tuple(L left, R right) {
this.left = left;
this.right = right;
}
/** Construct a blank tuple. */
public Tuple() {
}
/**
* Returns the combined hashcode of the two elements.
*/
public int hashCode() {
return left.hashCode() ^ rig