ucar.multiarray
Class ConcreteIndexMap.ZZMap

java.lang.Object
  extended byucar.multiarray.ConcreteIndexMap.ZZMap
Enclosing class:
ConcreteIndexMap

protected class ConcreteIndexMap.ZZMap
extends Object

An Map of int by int key. (Z is the math symbol for integers). A Map maps keys to values. A Map cannot contain duplicate keys; each key can map to at most one value. For this implementation, the keys are restricted to non-negative integers, and we only use non-negative integers as values.

A ZZMap is like a readonly 1-d array of int. The size() method returns the array length. The get(int ii) method returns the int stored at position ii;

This class also supports a functional composition framework via the setPrev() method. The implementation of get(int) and size() provided here is simply the identity composed with whatever. Subclasses will override this functionality.


Constructor Summary
protected ConcreteIndexMap.ZZMap()
           
protected ConcreteIndexMap.ZZMap(ConcreteIndexMap.ZZMap prev)
          Construct a ZZMap form the functional composition of the new Map with another.
 
Method Summary
(package private)  int get(int key)
          Returns the value to which this Map maps the specified key.
(package private)  void rebind(int[] range)
          Rebind (redefine) the range of get(int)
(package private)  void setPrev(ConcreteIndexMap.ZZMap prev)
          Form the functional composition of this Map with another.
(package private)  int size()
          Returns the number of key-value mappings in this Map.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConcreteIndexMap.ZZMap

protected ConcreteIndexMap.ZZMap()

ConcreteIndexMap.ZZMap

protected ConcreteIndexMap.ZZMap(ConcreteIndexMap.ZZMap prev)
Construct a ZZMap form the functional composition of the new Map with another. rebind(int [] range) calls prev.rebind(range), get(int key) is composed as get(prev.get(key))

Parameters:
prev - ZZMap this is composed with.
Method Detail

get

int get(int key)
Returns the value to which this Map maps the specified key. If you think of this as a 1-d array of int, then ia.get(ii) is like ia[ii].

Parameters:
key - int
Returns:
int value

rebind

final void rebind(int[] range)
Rebind (redefine) the range of get(int)

Parameters:
range - int array which defines the get(int) member.

size

int size()
Returns the number of key-value mappings in this Map. If you think of this as a 1-d array of int, then ia.size() is like ia.length.

Returns:
int size

setPrev

final void setPrev(ConcreteIndexMap.ZZMap prev)
Form the functional composition of this Map with another. rebind(int [] range) calls prev.rebind(range), get(int key) is composed as get(prev.get(key))

Parameters:
prev - ZZMap this is composed with.

toString

public String toString()