/[cashew-s-editor]/cashews/src/nongnu/cashews/commons/Pair.java
ViewVC logotype

Diff of /cashews/src/nongnu/cashews/commons/Pair.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by gnu_andrew, Sat Apr 9 22:11:10 2005 UTC revision 1.3 by gnu_andrew, Sun Apr 17 18:35:32 2005 UTC
# Line 21  Line 21 
21    
22  package nongnu.cashews.commons;  package nongnu.cashews.commons;
23    
24    import java.io.Serializable;
25    
26  /**  /**
27   * A small helper class to pair up two arbitrary heterogenously-typed   * A small helper class to pair up two arbitrary heterogenously-typed
28   * values.  This is where we wish we had a tuple data type.   * values.  This is where we wish we had a tuple data type.
# Line 28  package nongnu.cashews.commons; Line 30  package nongnu.cashews.commons;
30   * @author Andrew John Hughes (gnu_andrew@member.fsf.org)   * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
31   */   */
32  public class Pair<A,B>  public class Pair<A,B>
33      implements Serializable
34  {  {
35    
36    /**    /**
37       * Serialization ID.
38       */
39      private static final long serialVersionUID = -1924824870778608765L;
40    
41      /**
42     * The left-hand value.     * The left-hand value.
43       *
44       * @serial the left-hand value.
45     */     */
46    private A left;    private A left;
47        
48    /**    /**
49     * The right-hand value.     * The right-hand value.
50       *
51       * @serial the right-hand value.
52     */     */
53    private B right;    private B right;
54        
55    /**    /**
56     * Constructs a new pair using the values specified.     * Constructs a new pair using the values specified.
57     *     *
58     * @param a the left-hand value.     * @param left the left-hand value.
59     * @param b the right-hand value.     * @param right the right-hand value.
60     */     */
61    public Pair(A left, B right)    public Pair(A left, B right)
62    {    {
# Line 96  public class Pair<A,B> Line 108  public class Pair<A,B>
108     * Returns true if the supplied object is also a pair, with equivalent     * Returns true if the supplied object is also a pair, with equivalent
109     * left and right-hand values.     * left and right-hand values.
110     *     *
111     * @param object the object to compare.     * @param obj the object to compare.
112     */     */
113    public boolean equals(Object obj)    public boolean equals(Object obj)
114    {    {
# Line 125  public class Pair<A,B> Line 137  public class Pair<A,B>
137        + 17 * right.hashCode();        + 17 * right.hashCode();
138    }    }
139    
140      /**
141       * Returns a <code>String</code> representation of the pair.
142       *
143       * @return a <code>String</code> representation.
144       */
145      public String toString()
146      {
147        return "(" + left + "," + right + ")";
148      }
149    
150  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26