## ucar.multiarray
Interface IndexMap

All Known Implementing Classes:
  ConcreteIndexMap

public interface IndexMap

This interface defines the services required by MultiArrayProxy to manipulate indexes and the dimensions of a MultiArray. There are two transformations represented. Each goes from `int []` to `int []`. (The `int` values should actually be non-negative, as array indexes or array sizes.)

The transform most often used takes a MultiArrayProxy index and returns an index suitable for accessing the hidden 'backing' MultiArray. The `int [] transform(int [] output, int [] input)` does this. Refer to this as the forward transform. The `setInput(int [] input)` procedure binds the input array reference to the forward transformation. The transformation of values in the input array is obtained by calling `int [] getTransformed(int [] output)`. Note that the reference to input is bound, not a copy. This allows changes in values of the input array to be reflected in subsequent calls to `getTransformed` with needing to call `setInput` again.

The other transform is used to determine the proxy shape. It takes the shape of the backing MultiArray as input. It goes in the opposite direction as the forward transform; refer to this as the reverse transform. (Note: it is not an inverse.) The `setLengths(int [] lengths)` is analogous to `setInput()` above. It is typically called once during MultiArrayProxy initialization. The function `int [] getLengths(int [] output)` is analogous to `getTransformed`. It is used to implement the proxy getLengths() method.

Method Summary
`int[]` `getLengths(int[] output)` Reverse transform the lengths, placing the results in `output.`
`int` `getOutputLength()` Return the length needed for an output vector.
`int` `getRank()` Return the length of input vectors.
`int[]` `getTransformed(int[] output)` Transform the current input, placing the results in `output.`
`void` `setInput(int[] input)` Rebind the domain of `getTransformed()`
`void` `setLengths(int[] lengths)` Initialize or reinitialize the IndexMap.
`int[]` `transform(int[] output, int[] input)` Perform the forward transform.

Method Detail

### getOutputLength

    public int getOutputLength()

  Return the length needed for an output vector. Will throw an exception if called before `setInput()`.

### setInput

    public void setInput(int[] input)

  Rebind the domain of `getTransformed()`

  Parameters:
    `input` - int array domain reference member.

### getTransformed

    public int[] getTransformed(int[] output)

  Transform the current input, placing the results in `output.

  `
  Parameters:
    `output` - int array storage for the result. The elements of `output are usually modified by this call.`
  Returns:
    output

### transform

    public int[] transform(int[] output,
                           int[] input)

  Perform the forward transform.

  This function is equivalent to `setInput(input); return getTransformed(output);`

  Parameters:
    `output` - int array storage for the result. The elements of `output are usually modified by this call.`
    `input` - int array which is the index to be transformed.
  Returns:
    output

### getRank

    public int getRank()

  Return the length of input vectors. Will throw an exception if called before `setLengths()`.

### setLengths

    public void setLengths(int[] lengths)

  Initialize or reinitialize the IndexMap. Binds the domain of `getLengths()`, `getRank()`.

  Parameters:
    `lengths` - int array representing the shape on the forward transform output.

### getLengths

    public int[] getLengths(int[] output)

  Reverse transform the lengths, placing the results in `output. Will throw an exception if called before `setLengths()`.

  `
  Parameters:
    `output` - int array storage for the result. The elements of `output are usually modified by this call.`
  Returns:
    output