code: public int next() {
          int index = getIndex(); // offset = getOffset() in ICU4C
          int matchindex = search_.matchedIndex_;
          int matchlength = search_.matchedLength();
          search_.reset_ = false;
          if (search_.isForwardSearching_) {
              int endIdx = search_.endIndex();
              if (index == endIdx || matchindex == endIdx ||
                      (matchindex != DONE &&
                      matchindex + matchlength >= endIdx)) {
                  setMatchNotFound();
                  return DONE;
              }
          } else {
              // switching direction.
              // if matchedIndex == DONE, it means that either a 
              // setIndex (setOffset in C) has been called or that previous ran off the text
              // string. the iterator would have been set to offset 0 if a 
              // match is not found.
              search_.isForwardSearching_ = true;
              if (search_.matchedIndex_ != DONE) {
                  // there's no need to set the collation element iterator
                  // the next call to next will set the offset.
                  return matchindex;
              }
          }
  
          if (matchlength > 0) {
              // if matchlength is 0 we are at the start of the iteration
              if (search_.isOverlap_) {
                  index++;
              } else {
                  index += matchlength;
              }
          }
  
          return handleNext(index);
      }
docs: Returns the index of the next point at which the text matches the
  search pattern, starting from the current position
  The iterator is adjusted so that its current index (as returned by
  {@link #getIndex}) is the match position if one was found.
  If a match is not found, {@link #DONE} will be returned and
  the iterator will be adjusted to a position after the end of the text
  string.
  
  @return The index of the next match after the current position,
  or {@link #DONE} if there are no more matches.
  @see #getIndex