Class IntArray


  extended by Object
      extended by IntArray

public class IntArray
extends Object

This class implements an facade for int[]. Size of array is fixed and cannot be changed after it is created.


Constructor Summary
IntArray(int length)
          Creates a new int[] with specified length.
 
Method Summary
 IntArray clear(int fill)
          Fills the whole array with specified integer.
 int length()
          Returns the length of this array.
 int operator_get(int index)
          Returns the integer at specified index.
 int operator_set(int index, int value)
          Sets the integer at specified index.
 IntArray set$(int offset)
          Sets multiple integers at once, starting from specified offset.
 IntArray setLength(int length)
          Creates a new array with specified length.
 
Methods inherited from class Object
toString, equals, hashCode
 
Methods inherited from
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntArray

public IntArray(int length)
Creates a new int[] with specified length.

Parameters:
length - Length of array, must be >= 0
Method Detail

operator_get

public int operator_get(int index)
Returns the integer at specified index.

Parameters:
index - Index to array
Returns:
integer at specified index

operator_set

public int operator_set(int index,
                        int value)
Sets the integer at specified index.

Parameters:
index - Index to array
value - New value for index
Returns:
value parameter

setLength

public IntArray setLength(int length)
Creates a new array with specified length. Initial contents are duplicated from this array. If new length is greater than length of this array the new indices are filled with zeros.

Parameters:
length - New length of array
Returns:
new IntArray instance

length

public int length()
Returns the length of this array.

Returns:
length of array

clear

public IntArray clear(int fill)
Fills the whole array with specified integer.

Parameters:
fill - Filler integer
Returns:
this IntArray
Since:
2.0.0

set$

public IntArray set$(int offset)
Sets multiple integers at once, starting from specified offset. Note that all the arguments must result integers - in some situation the forced cast is needed. Arguments that are out of array range are silently ignored.
 int a = ...;
 IntArray matrix = 
   new IntArray(9).set(0,, -a-1, -a, -a+1, 
                             -1,  0,    1,
                            a-1,  a,  a+1);
 

Parameters:
offset - Offset to start setting from
Returns:
this IntArray
Since:
2.0.0