comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/IJKey.java @ 798:6cff63d0c434

Fixed vim modeline. Added some Javadoc. gnv-artifacts/trunk@880 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 06 Apr 2010 11:05:00 +0000
parents c4156275c1e1
children d766fe2d917a
comparison
equal deleted inserted replaced
797:9d2891068ba5 798:6cff63d0c434
1 package de.intevation.gnv.math; 1 package de.intevation.gnv.math;
2 2
3 import java.io.Serializable; 3 import java.io.Serializable;
4 4
5 /** 5 /**
6 * Tuple (i, j) to model a pair of integers. Useful to store index pairs
7 * in maps.
6 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> 8 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
7 */ 9 */
8 public class IJKey 10 public class IJKey
9 implements Serializable 11 implements Serializable
10 { 12 {
13 /**
14 * i component of the tuple.
15 */
11 public int i; 16 public int i;
17 /**
18 * j component of the tuple.
19 */
12 public int j; 20 public int j;
13 21
22 /**
23 * Default constructor.
24 */
14 public IJKey() { 25 public IJKey() {
15 } 26 }
16 27
28 /**
29 * Constructor to set i and j.
30 * @param i The i component.
31 * @param j The j component.
32 */
17 public IJKey(int i, int j) { 33 public IJKey(int i, int j) {
18 this.i = i; 34 this.i = i;
19 this.j = j; 35 this.j = j;
20 } 36 }
21 37
38 /**
39 * Orders i and j by their values.
40 */
22 public void sort() { 41 public void sort() {
23 if (i > j) { 42 if (i > j) {
24 int t = i; 43 int t = i;
25 i = j; 44 i = j;
26 j = t; 45 j = t;
27 } 46 }
28 } 47 }
29 48
49 /**
50 * Hashes i and j into a common value.
51 * @return
52 */
53 @Override
30 public int hashCode() { 54 public int hashCode() {
31 return (i << 16) | j; 55 return (i << 16) | j;
32 } 56 }
33 57
58 /**
59 * IJKeys are considered equal if the i and j components
60 * are equal.
61 * @param obj The other IJKey
62 * @return true if the IJKeys are equal else false.
63 */
64 @Override
34 public boolean equals(Object obj) { 65 public boolean equals(Object obj) {
66 if (!(obj instanceof IJKey)) {
67 return false;
68 }
35 IJKey other = (IJKey)obj; 69 IJKey other = (IJKey)obj;
36 return i == other.i && j == other.j; 70 return i == other.i && j == other.j;
37 } 71 }
38 } 72 }
39 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: 73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org