private void advance()

in jflex/src/main/java/jflex/state/StateSetEnumerator.java [86:134]


  private void advance() {

    if (DEBUG) Out.dump("Advancing, at start, index = " + index + ", offset = " + offset);

    // cache fields in local variable for faster access
    int _index = this.index;
    int _offset = this.offset;
    long _mask = this.mask;
    long[] _bits = this.bits;

    long bi = _bits[_index];

    // check if there are further bits set at the current index
    do {
      _offset++;
      _mask <<= 1;
    } while (_offset <= StateSet.MASK && ((bi & _mask) == 0));

    // if there are no further bits set at the current index
    if (_offset > StateSet.MASK) {
      int length = _bits.length;

      // find next index with elements
      do _index++;
      while (_index < length && _bits[_index] == 0);

      // if there are none, there were no further elements
      if (_index >= length) {
        this.index = length; // indicates "no more elements"
        return;
      }

      // search for first non-zero bit in bits[index]
      _offset = 0;
      _mask = 1;
      bi = _bits[_index];

      // terminates, because bi != 0
      while ((bi & _mask) == 0) {
        _mask <<= 1;
        _offset++;
      }
    }

    // write back cached values
    this.index = _index;
    this.mask = _mask;
    this.offset = _offset;
  }