ist.palcom.base
Class Array

java.lang.Object
  extended by ist.palcom.base.Object
      extended by ist.palcom.base.ReadableArray
          extended by ist.palcom.base.Array
Direct Known Subclasses:
CheckedArray

public class Array
extends ReadableArray

Array is a system class that represents an mutable sequence of objects. The index of the first element is 0. The size of an array is fixed at creation time.


Constructor Summary
Array()
          Creates a new empty array.
Array(Integer size, Block block)
          Creates an array with the specified size.
Array(List list)
          Creates an array containing all values in the specified list in the same order.
Array(Object object, Object anotherObject)
          Creates an array with two values: object and anotherObject.
 
Method Summary
 void at(set name, Integer index, Object value)
          Replaces the value at the specified position with the specified value.
 void putAll(Block block)
          Replaces the value at all indeces with the result of evaluating the specified block with the index as argument.
 Array sort()
          Returns a sorted copy of this array.
 Array sortFrom(Integer from, Integer to)
          Returns a sorted copy of the values of this array ranging from from to (to - 1).
 
Methods inherited from class ist.palcom.base.ReadableArray
at, length
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Array

public Array(Integer size,
             Block block)
Creates an array with the specified size. The values of the array will be supplied by evaluating the specified block with each index as argument.

Parameters:
size - Integer size of new array
block - Block block to supply the values

Array

public Array(List list)
Creates an array containing all values in the specified list in the same order.

Parameters:
list - List list with values to be used to create new array

Array

public Array(Object object,
             Object anotherObject)
Creates an array with two values: object and anotherObject.

Parameters:
object - Object the first value in the new array
anotherObject - Object the second value in the new array

Array

public Array()
Creates a new empty array.

Method Detail

putAll

public void putAll(Block block)
Replaces the value at all indeces with the result of evaluating the specified block with the index as argument.

Parameters:
block - Block block that takes the index as argument

sort

public Array sort()
Returns a sorted copy of this array.

Returns:
Array a sorted copy of this array

sortFrom

public Array sortFrom(Integer from,
                      Integer to)
Returns a sorted copy of the values of this array ranging from from to (to - 1).

Parameters:
from - Integer first index in the range
to - Integer the value 1 larger than the last index in range
Returns:
Array a sorted copy of the specified range of values

at

public void at(set name,
               Integer index,
               Object value)
Replaces the value at the specified position with the specified value.

Parameters:
name - set
index - Integer index of the element to replace
value - Object value to be stored at the specified position