cdm/src/main/java/ucar/ma2/Range.java
public int index(int want) throws InvalidRangeException {
    if (want < first)
      throw new InvalidRangeException("elem must be >= first");
    int result = (want - first) / stride;
    if (result > length)
      throw new InvalidRangeException("elem must be <= first = n * stride");
    return result;
  }
public int index(int want) throws InvalidRangeException {
    if (want < first)
      throw new InvalidRangeException("elem must be >= first");
    int result = (want - first) / stride;
    if (result > length)
      throw new InvalidRangeException("elem must be <= first = n * stride");
    return result;
  }
Get the index for this element: inverse of element

@param want the element of the range
@return index
@throws InvalidRangeException if illegal elem