|
jjdh API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjjdh.java.math.Index2D
public final class Index2D
The Class Index2D
models a position of the form (row, column) in a
2-dimensional coordinate system.
Field Summary | |
---|---|
private int |
column
The column of this position. |
private int |
row
The row of this position. |
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
Index2D()
Initializes this Position2D with the values
(row, column) = (0, 0) . |
|
Index2D(int row,
int column)
Initializes this Position2D with the given values. |
Method Summary | |
---|---|
Object |
clone()
Creates and returns a real, deep copy of this object. |
int |
compareTo(Index2D other)
Compares some other Position2D with this one for order. |
boolean |
equals(Object obj)
Indicates wheather some other Position2D/code> is "equal to" this one. |
int |
getColumn()
Returns the Column of this position. |
Index2D |
getDeferred(int changeRow,
int changeColumn)
Creates and returns a new Position2D which is deferred by
the given values in relation to this Position2D . |
int |
getRow()
Returns the Row of this position. |
int |
hashCode()
Calculates a hash code value for this Position2D . |
static int |
hashCode(int a,
int b)
Calculates a hash code value for the two given ints. |
static int |
taxiDistance(Index2D pos1,
Index2D pos2)
Calculates the taxi - distance between the two given Positions. |
static int |
taxiDistance(int pos1Row,
int pos1Col,
int pos2Row,
int pos2Col)
Calculates the taxi - distance between the two given Positions. |
String |
toString()
Returns a textual representation of this position. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private final int row
private final int column
Constructor Detail |
---|
public Index2D()
Position2D
with the values
(row, column) = (0, 0)
.
public Index2D(int row, int column)
Position2D
with the given values.
row
- the Row of this position.column
- the Column of this position.Method Detail |
---|
public Object clone()
clone
in class Object
public final int getRow()
public final int getColumn()
public static final int taxiDistance(int pos1Row, int pos1Col, int pos2Row, int pos2Col)
Note: The taxi - metric is also called as Manhattan - metric.
pos1Row
- the row of the fist Position.pos1Col
- the col of the fist Position.pos2Row
- the row of the second Position.pos2Col
- the col of the second Position.
public static final int taxiDistance(Index2D pos1, Index2D pos2)
Note: The taxi - metric is also called as Manhattan - metric.
pos1
- the fist Position.pos2
- the second Position.
public final Index2D getDeferred(int changeRow, int changeColumn)
Position2D
which is deferred by
the given values in relation to this Position2D
.
changeRow
- the deviant of the Row.changeColumn
- the derivant of the Column.
Position2D
.public final String toString()
The result is of the form (row, column)
, so that the
String contains no line breaks.
toString
in class Object
public final int compareTo(Index2D other)
Position2D
with this one for order.
compareTo
in interface Comparable<Index2D>
public static final int hashCode(int a, int b)
The method is not commutative, that means the chronological order of the
arguments is relevant for the result. Furthermore, this method is
injective for values a, b < 250
.
Mathematically, this method is a conversion of Cantor's diagonal technique.
a
- the fist int
.b
- the second int
.
public final int hashCode()
Position2D
.
hashCode
in class Object
Position2D
.hashCode(int a, int b)
public final boolean equals(Object obj)
Position2D/code> is "equal to" this one.
Note: Two 2-dimensional positions should be detected as "equal" if they cover the same content, and not only if they are the same object.
- Overrides:
equals
in class Object
- Parameters:
obj
- the reference object with which to compare.
- Returns:
- true if this object covers the same content as the obj argument; false otherwise.
|
jjdh API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |