## ucar.multiarray
Class ConcreteIndexMap

    java.lang.Object
      ucar.multiarray.ConcreteIndexMap

All Implemented Interfaces:
  IndexMap

Direct Known Subclasses:
  ClipMap, DecimateMap, FlattenMap, FlipMap, SliceMap, TransposeMap

public class ConcreteIndexMap
extends Object
implements IndexMap

Base class which provides framework for implementations of IndexMap. This class contains two instances of the inner class ZZMap, which are used to implement the two transformations required by IndexMap.

This class also supports a functional composition framework via the link() initializer.

All methods except contructors are final. Specialization in subclasses occurs by subclassing the ZZMap inner class. Subclasses provide different ZZMaps during construction.

This specialization strategy results in an implementation oddity. When instances of a subclass of this are being constructed, this class's constructor (as super(...)) must complete before instances of the subclass inner class may be created. "Can't reference this before the superclass constructor has been called." So, rather that initializing the ZZMap members contained by this in the constructors, we provide init() and link() members functions. One or the other of these should be called by every subclass constructor.

Nested Class Summary
`protected class` `ConcreteIndexMap.ZZMap` An Map of int by int key.

Field Summary
`protected ConcreteIndexMap.ZZMap` `iMap_` Supports the forward tranform.
`protected ConcreteIndexMap.ZZMap` `lengthsMap_` Supports the reverse tranform.

Constructor Summary
`protected` `ConcreteIndexMap()` Only constructor is protected.

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.`
`protected void` `init(ConcreteIndexMap.ZZMap iMap)` Called by subclass constructors to initialize.
`protected void` `init(ConcreteIndexMap.ZZMap iMap, ConcreteIndexMap.ZZMap lengthsMap)` Called by subclass constructors to initialize.
`protected void` `link(ConcreteIndexMap prev, ConcreteIndexMap.ZZMap iMap)` Called by subclass constructors to initialize.
`protected void` `link(ConcreteIndexMap prev, ConcreteIndexMap.ZZMap iMap, ConcreteIndexMap.ZZMap lengthsMap)` Called by subclass constructors to initialize.
`static void` `main(String[] args)`
`void` `setInput(int[] input)` Rebind the domain of `getTransformed()`
`void` `setLengths(int[] lengths)` Initialize or reinitialize the IndexMap.
`String` `toString()`
`int[]` `transform(int[] output, int[] input)` Perform the forward transform.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### iMap_

    protected ConcreteIndexMap.ZZMap iMap_

  Supports the forward tranform.

### lengthsMap_

    protected ConcreteIndexMap.ZZMap lengthsMap_

  Supports the reverse tranform.

Constructor Detail

### ConcreteIndexMap

    protected ConcreteIndexMap()

  Only constructor is protected. This is a base class, clients only create instances of the subclasses.

Method Detail

### init

    protected final void init(ConcreteIndexMap.ZZMap iMap,
                              ConcreteIndexMap.ZZMap lengthsMap)

  Called by subclass constructors to initialize. Used for standalone or "leaf" instances. See "implementation oddity" above.

  Parameters:
    `iMap` - ZZMap defining the forward transform.
    `lengthsMap` - ZZMap defining the reverse transform.

### init

    protected final void init(ConcreteIndexMap.ZZMap iMap)

  Called by subclass constructors to initialize. Used for standalone or "leaf" instances when the reverse transformation (lengthsMap) is the identity. See "implementation oddity" above.

  Parameters:
    `iMap` - ZZMap defining the forward transform.

### link

    protected final void link(ConcreteIndexMap prev,
                              ConcreteIndexMap.ZZMap iMap,
                              ConcreteIndexMap.ZZMap lengthsMap)

  Called by subclass constructors to initialize. Used when nested constructors are used to form functional composition of IndexMaps. See "implementation oddity" above.

  Parameters:
    `prev` - ConcreteIndexMap this is composed with.
    `iMap` - ZZMap defining the forward transform.
    `lengthsMap` - ZZMap defining the reverse transform.

### link

    protected final void link(ConcreteIndexMap prev,
                              ConcreteIndexMap.ZZMap iMap)

  Called by subclass constructors to initialize. Used when nested constructors are used to form functional composition of IndexMaps. This form is used when the reverse transform (lengthsMap) is the identity See "implementation oddity" above.

  Parameters:
    `prev` - ConcreteIndexMap this is composed with.
    `iMap` - ZZMap defining the forward transform.

### getOutputLength

    public final int getOutputLength()

  Description copied from interface: `IndexMap`
  Return the length needed for an output vector. Will throw an exception if called before `setInput()`.

  Specified by:
    `getOutputLength` in interface `IndexMap`

### setInput

    public final void setInput(int[] input)

  Description copied from interface: `IndexMap`
  Rebind the domain of `getTransformed()`

  Specified by:
    `setInput` in interface `IndexMap`
  Parameters:
    `input` - int array domain reference member.

### getTransformed

    public final int[] getTransformed(int[] output)

  Description copied from interface: `IndexMap`
  Transform the current input, placing the results in `output.

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

### transform

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

  Description copied from interface: `IndexMap`
  Perform the forward transform.

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

  Specified by:
    `transform` in interface `IndexMap`
  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 final int getRank()

  Description copied from interface: `IndexMap`
  Return the length of input vectors. Will throw an exception if called before `setLengths()`.

  Specified by:
    `getRank` in interface `IndexMap`

### setLengths

    public final void setLengths(int[] lengths)

  Description copied from interface: `IndexMap`
  Initialize or reinitialize the IndexMap. Binds the domain of `getLengths()`, `getRank()`.

  Specified by:
    `setLengths` in interface `IndexMap`
  Parameters:
    `lengths` - int array representing the shape on the forward transform output.

### getLengths

    public final int[] getLengths(int[] output)

  Description copied from interface: `IndexMap`
  Reverse transform the lengths, placing the results in `output. Will throw an exception if called before `setLengths()`.

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

### toString

    public String toString()

### main

    public static void main(String[] args)