org.openmali.vecmath2
Class Tuple2i

java.lang.Object
  extended by org.openmali.vecmath2.TupleNi<Tuple2i>
      extended by org.openmali.vecmath2.Tuple2i
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
Point2i, Vector2i

public class Tuple2i
extends TupleNi<Tuple2i>

A simple two-dimensional tuple implementation. Inspired by Kenji Hiranabe's Tuple2i implementation

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.openmali.vecmath2.TupleNi
isDirty, N, roTrick, values
 
Constructor Summary
  Tuple2i()
          Creates a new Tuple2i instance.
protected Tuple2i(boolean readOnly)
          Creates a new Tuple2i instance.
protected Tuple2i(boolean readOnly, int[] values, boolean[] isDirty, boolean copy)
          Creates a new Tuple2i instance.
protected Tuple2i(boolean readOnly, int x, int y)
          Creates a new Tuple2i instance.
protected Tuple2i(boolean readOnly, Tuple2i that)
          Creates a new Tuple2i instance.
  Tuple2i(int[] values)
          Creates a new Tuple2i instance.
  Tuple2i(int x, int y)
          Creates a new Tuple2i instance.
  Tuple2i(Tuple2i that)
          Creates a new Tuple2i instance.
 
Method Summary
 Tuple2i add(int x, int y)
          Adds the given parameters to this tuple's values.
 Tuple2i addX(int v)
          Adds v to this tuple's x value.
 Tuple2i addY(int v)
          Adds v to this tuple's y value.
 Tuple2i asReadOnly()
          
 Tuple2i clone()
          Creates and returns a copy of this object.
 Tuple2i div(int vx, int vy)
          Divides this tuple's values by vx, vy, vz.
 Tuple2i divX(int v)
          Divides this tuple's x value by v.
 Tuple2i divY(int v)
          Divides this tuple's y value by v.
 boolean equals(java.lang.Object tuple2)
          Returns true if the Object t1 is of type Tuple3f and all of the data members of t1 are equal to the corresponding data members in this Tuple2f.
 boolean equals(Tuple2i tuple2)
          Returns true if all of the data members of GVector vector1 are equal to the corresponding data members in this GVector.
static Tuple2i fromPool()
          Allocates an Tuple2i instance from the pool.
static Tuple2i fromPool(int x, int y)
          Allocates an Tuple2i instance from the pool.
static Tuple2i fromPool(Tuple2i tuple)
          Allocates an Tuple2i instance from the pool.
 Tuple2i getReadOnly()
          
 int getX()
           
 int getY()
           
 int hashCode()
          Returns a hash number based on the data values in this object.
 Tuple2i mul(int vx, int vy)
          Multiplies this tuple's values with vx, vy.
 Tuple2i mulX(int v)
          Multiplies this tuple's x value with v.
 Tuple2i mulY(int v)
          Multiplies this tuple's y value with v.
static Tuple2i newReadOnly()
          Creates a new Tuple2i instance.
static Tuple2i newReadOnly(int[] values)
          Creates a new Tuple2i instance.
static Tuple2i newReadOnly(int x, int y)
          Creates a new Tuple2i instance.
static Tuple2i newReadOnly(Tuple2i tuple)
          Creates a new Tuple2i instance.
 Tuple2i scale(int factorX, int factorY)
          Sets the value of this tuple to the scalar multiplication of tuple t1.
 Tuple2i set(int x, int y)
          Sets all three values of this Tuple to the specified ones.
 Tuple2i setX(int x)
          Sets the value of the x-element of this tuple.
 Tuple2i setY(int y)
          Sets the value of the y-element of this tuple.
 Tuple2i sub(int x, int y)
          Subtracts the given parameters from this tuple's values.
 Tuple2i subX(int v)
          Subtracts v from this tuple's x value.
 Tuple2i subY(int v)
          Subtracts v from this tuple's y value.
static void toPool(Tuple2i o)
          Stores the given Tuple2i instance in the pool.
 java.lang.String toString()
          Returns a string that contains the values of this Tuple2f.
 int x()
           
 Tuple2i x(int x)
          Sets the value of the x-element of this tuple.
 int y()
           
 Tuple2i y(int y)
          Sets the value of the y-element of this tuple.
 
Methods inherited from class org.openmali.vecmath2.TupleNi
absolute, absolute, add, add, clamp, clamp, clampMax, clampMax, clampMin, clampMin, deserialize, get, get, get, getSerializationBufferSize, getSize, getValue, isDirty, isReadOnly, negate, negate, readExternal, scale, scale, scaleAdd, scaleAdd, serialize, set, set, set, setClean, setValue, setZero, sub, sub, writeExternal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tuple2i

protected Tuple2i(boolean readOnly,
                  int x,
                  int y)
Creates a new Tuple2i instance.

Parameters:
readOnly -
x - the x element to use
y - the y element to use

Tuple2i

protected Tuple2i(boolean readOnly,
                  int[] values,
                  boolean[] isDirty,
                  boolean copy)
Creates a new Tuple2i instance.

Parameters:
readOnly -
values - the values array (must be at least size 2)
isDirty - the isDirty-value
copy - copy the array?

Tuple2i

protected Tuple2i(boolean readOnly,
                  Tuple2i that)
Creates a new Tuple2i instance.

Parameters:
readOnly -
that - the Tuple2i to copy the values from

Tuple2i

protected Tuple2i(boolean readOnly)
Creates a new Tuple2i instance.

Parameters:
readOnly -

Tuple2i

public Tuple2i(int x,
               int y)
Creates a new Tuple2i instance.

Parameters:
x - the x element to use
y - the y element to use

Tuple2i

public Tuple2i(int[] values)
Creates a new Tuple2i instance.

Parameters:
values - the values array (must be at least size 2)

Tuple2i

public Tuple2i(Tuple2i that)
Creates a new Tuple2i instance.

Parameters:
that - the Tuple2i to copy the values from

Tuple2i

public Tuple2i()
Creates a new Tuple2i instance.

Method Detail

setX

public final Tuple2i setX(int x)
Sets the value of the x-element of this tuple.

Parameters:
x -
Returns:
itself

setY

public final Tuple2i setY(int y)
Sets the value of the y-element of this tuple.

Parameters:
y -
Returns:
itself

getX

public final int getX()
Returns:
the value of the x-element of this tuple.

getY

public final int getY()
Returns:
the value of the y-element of this tuple.

x

public final Tuple2i x(int x)
Sets the value of the x-element of this tuple.

Parameters:
x -
Returns:
itself

y

public final Tuple2i y(int y)
Sets the value of the y-element of this tuple.

Parameters:
y -
Returns:
itself

x

public final int x()
Returns:
the value of the x-element of this tuple.

y

public final int y()
Returns:
the value of the y-element of this tuple.

set

public final Tuple2i set(int x,
                         int y)
Sets all three values of this Tuple to the specified ones.

Parameters:
x - the x element to use
y - the y element to use
Returns:
itself

addX

public final Tuple2i addX(int v)
Adds v to this tuple's x value.

Parameters:
v -
Returns:
itself

addY

public final Tuple2i addY(int v)
Adds v to this tuple's y value.

Parameters:
v -
Returns:
itself

add

public final Tuple2i add(int x,
                         int y)
Adds the given parameters to this tuple's values.

Parameters:
x -
y -
Returns:
itself

subX

public final Tuple2i subX(int v)
Subtracts v from this tuple's x value.

Parameters:
v -
Returns:
itself

subY

public final Tuple2i subY(int v)
Subtracts v from this tuple's y value.

Parameters:
v -
Returns:
itself

sub

public final Tuple2i sub(int x,
                         int y)
Subtracts the given parameters from this tuple's values.

Parameters:
x -
y -
Returns:
itself

mulX

public final Tuple2i mulX(int v)
Multiplies this tuple's x value with v.

Parameters:
v -
Returns:
itself

mulY

public final Tuple2i mulY(int v)
Multiplies this tuple's y value with v.

Parameters:
v -
Returns:
itself

mul

public final Tuple2i mul(int vx,
                         int vy)
Multiplies this tuple's values with vx, vy.

Parameters:
vx -
vy -
Returns:
itself

divX

public final Tuple2i divX(int v)
Divides this tuple's x value by v.

Parameters:
v -
Returns:
itself

divY

public final Tuple2i divY(int v)
Divides this tuple's y value by v.

Parameters:
v -
Returns:
itself

div

public final Tuple2i div(int vx,
                         int vy)
Divides this tuple's values by vx, vy, vz.

Parameters:
vx -
vy -
Returns:
itself

scale

public final Tuple2i scale(int factorX,
                           int factorY)
Sets the value of this tuple to the scalar multiplication of tuple t1.

Parameters:
factorX -
factorY -
Returns:
itself

asReadOnly

public Tuple2i asReadOnly()

Specified by:
asReadOnly in class TupleNi<Tuple2i>
Returns:
a new instance sharing the values array with this instance. The new instance is read-only. Changes to this instance will be reflected in the new read-only-instance.
See Also:
TupleNi.getReadOnly()

getReadOnly

public Tuple2i getReadOnly()

Specified by:
getReadOnly in class TupleNi<Tuple2i>
Returns:
a single instance sharing the values array with this instance (one unique instance per 'master-instance'). The instance is read-only. Changes to this instance will be reflected in the read-only-instance.
See Also:
TupleNi.asReadOnly()

hashCode

public int hashCode()
Returns a hash number based on the data values in this object. Two different Tuple3f objects with identical data values (ie, returns true for equals(Tuple3f) ) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.

Specified by:
hashCode in class TupleNi<Tuple2i>

equals

public boolean equals(Tuple2i tuple2)
Returns true if all of the data members of GVector vector1 are equal to the corresponding data members in this GVector.

Overrides:
equals in class TupleNi<Tuple2i>
Parameters:
tuple2 - The vector with which the comparison is made.
Returns:
true or false

equals

public boolean equals(java.lang.Object tuple2)
Returns true if the Object t1 is of type Tuple3f and all of the data members of t1 are equal to the corresponding data members in this Tuple2f.

Overrides:
equals in class TupleNi<Tuple2i>
Parameters:
tuple2 - the Object with which the comparison is made
Returns:
true or false

toString

public java.lang.String toString()
Returns a string that contains the values of this Tuple2f. The form is (x, y).

Specified by:
toString in class TupleNi<Tuple2i>
Returns:
the String representation

clone

public Tuple2i clone()
Creates and returns a copy of this object.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.
Throws:
java.lang.OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable

newReadOnly

public static Tuple2i newReadOnly(int x,
                                  int y)
Creates a new Tuple2i instance.

Parameters:
x - the x element to use
y - the y element to use

newReadOnly

public static Tuple2i newReadOnly(int[] values)
Creates a new Tuple2i instance.

Parameters:
values - the values array (must be at least size 2)

newReadOnly

public static Tuple2i newReadOnly(Tuple2i tuple)
Creates a new Tuple2i instance.

Parameters:
tuple - the Tuple2i to copy the values from

newReadOnly

public static Tuple2i newReadOnly()
Creates a new Tuple2i instance.


fromPool

public static Tuple2i fromPool()
Allocates an Tuple2i instance from the pool.


fromPool

public static Tuple2i fromPool(int x,
                               int y)
Allocates an Tuple2i instance from the pool.


fromPool

public static Tuple2i fromPool(Tuple2i tuple)
Allocates an Tuple2i instance from the pool.


toPool

public static void toPool(Tuple2i o)
Stores the given Tuple2i instance in the pool.

Parameters:
o -