001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.nbio.structure.quaternary; 022 023/** 024 * An ordered pair represents a component of a cartesian product. The cartesian product 025 * of two sets A and B is the set of all ordered pairs of the elements of both sets. 026 * 027 * See http://en.wikipedia.org/wiki/Cartesian_product for more details. 028 * 029 * Example: 030 * A = {1, 2, 3} 031 * B = {4, 5} 032 * The ordered pairs are {1, 4}, {1, 5}, {2, 4}, .., {3, 5} 033 * 034 * @author Peter Rose 035 * 036 * @param <T> 037 */ 038public class OrderedPair<T> { 039 T element1; 040 T element2; 041 042 /** 043 * Class constructor specifying the two elements of an ordered pair. 044 */ 045 OrderedPair(T element1, T element2) { 046 this.element1 = element1; 047 this.element2 = element2; 048 } 049 050 /** 051 * @return element1 the first element of an ordered pair 052 */ 053 public T getElement1() { 054 return element1; 055 } 056 057 /** 058 * Sets the first element of an ordered pair. 059 * 060 * @param element1 the first element of an ordered pair 061 */ 062 public void setElement1(T element1) { 063 this.element1 = element1; 064 } 065 066 /** 067 * @return element2 the second element of an ordered pair 068 */ 069 public T getElement2() { 070 return element2; 071 } 072 073 /** 074 * Sets the second element of an ordered pair. 075 * 076 * @param element2 the second element of an ordered pair 077 */ 078 public void setElement2(T element2) { 079 this.element2 = element2; 080 } 081 082 @Override 083 public String toString() { 084 return "[" + element1.toString() + "," + 085 element2.toString() + "]"; 086 } 087}