code: public int next() {
          int curIndex = _index;
          // Compute the next index.
          if( _index >= 0 ) {
              int i = _state.length - 1;
  
              while( i >= 0 ) {
                  _index += _sum[i];
                  if( ++_state[i] < _ranges[i] )
                      break;
                  _index -= _sum[i] * _ranges[i];
                  _state[i] = 0;
                  i--;
              }
  
              if( i == -1 )
                  _index = -1;
          }
          // Return the current index.
          return curIndex;
      }
docs: Increments the current state of \a forVars (prefix) and returns linear index of the current state of indexVars.