Returns the index of marker in {@code chars}, stopping at {@code limit}.
Should the chars end with a prefix of marker, the offset of that prefix
is returned.
489281
int findPossibleMarker(char[] chars, int limit) {
    search:
    for (int i = 0; true; i++) {
      for (int m = 0; m < marker.length() && i + m < limit; m++) {
        if (chars[i + m] != marker.charAt(m)) {
          continue search;
        }
      }
      return i;
    }
  }
1353546
public char setIndex(int pos) 
  { 
    if (pos < 0) {
      _pos = 0;
      return DONE;
    }
    else if (_length <= pos) {
      _pos = _length;
      return DONE;
    }
    else {
      _pos = pos; 
      return _string.charAt(pos);
    }
  }
1204310
private int getStartingPoint(String buffer) {
    for (int i = 0; i < buffer.length(); i++) {
      if (!Character.isWhitespace(buffer.charAt(i))) {
        return i;
      }
    }
    return buffer.length();
  }
55137
int nextIndexOf(char c) {
        // doesn't handle scanning for surrogates
        bufferUp();
        for (int i = bufPos; i < bufLength; i++) {
            if (c == charBuf[i])
                return i - bufPos;
        }
        return -1;
    }
83874
public static Optional<OffsetRange<CharOffset>> charOffsetsOfWholeString(String s) {
    if (s.isEmpty()) {
      return Optional.absent();
    }
    return Optional.of(charOffsetRange(0, s.length() - 1));
  }
579478
protected int getLastNumPos(final String s) {
        int i = 0;
        for ( ; i < s.length(); i++) {
            if (NUM_CHARS.indexOf(s.charAt(i)) < 0) {
                break;
            }
        }
        return i - 1;
    }
590577
final int getIndexValue() {
        if (anteContextLength == pattern.length()) {
            // A pattern with just ante context {such as foo)>bar} can
            // match any key.
            return -1;
        }
        int c = UTF16.charAt(pattern, anteContextLength);
        return data.lookupMatcher(c) == null ? (c & 0xFF) : -1;
    }
1291395
public int getMatchLen(int index, int distance, int limit)
    {
        if (_streamEndWasReached)
        {
            if ((_pos + index) + limit > _streamPos)
            {
                limit = _streamPos - (_pos + index);
            }
        }
        distance++;
        // Byte *pby = _buffer + (size_t)_pos + index;
        int pby = _bufferOffset + _pos + index;

        int i;
        for (i = 0; i < limit && _bufferBase[pby + i] == _bufferBase[pby + i - distance]; i++)
        {
        }
        return i;
    }
1320001
@Override
    public char next() {
        ++docPos;
        if (docPos < segmentEnd || segmentEnd >= doc.getLength()) {
            return text.next();
        }
        try {
            doc.getText(segmentEnd, doc.getLength() - segmentEnd, text);
        } catch (BadLocationException e) {
            throw new RuntimeException(e);
        }
        segmentEnd += text.count;
        return text.current();
    }
1277927
public static int lineEnd(ByteBuffer buffer, int maxLength) {
		int primitivePosition = buffer.position();
		boolean canEnd = false;
		int charIndex = primitivePosition;
		byte b;
		while (buffer.hasRemaining()) {
			b = buffer.get();
			charIndex++;
			if (b == StrUtil.C_CR) {
				canEnd = true;
			} else if (b == StrUtil.C_LF) {
				return canEnd ? charIndex - 2 : charIndex - 1;
			} else {
				// 只有\r无法确认换行
				canEnd = false;
			}

			if (charIndex - primitivePosition > maxLength) {
				// 查找到尽头，未找到，还原位置
				buffer.position(primitivePosition);
				throw new IndexOutOfBoundsException(StrUtil.format("Position is out of maxLength: {}", maxLength));
			}
		}

		// 查找到buffer尽头，未找到，还原位置
		buffer.position(primitivePosition);
		// 读到结束位置
		return -1;
	}
320259
def character_offset_begin(self):
        
        if self._character_offset_begin is None:
            offsets = self._element.xpath('CharacterOffsetBegin/text()')
            if len(offsets) > 0:
                self._character_offset_begin = int(offsets[0])
        return self._character_offset_begin
1189784
private static String prefix(String s, int start) {
        StringBuilder prefix=new StringBuilder(MAX_PREFIX_LENGTH+20);
        if(start==0) {
            prefix.append("\"");
        } else {
            prefix.append("[at pattern index ").append(start).append("] \"");
        }
        int substringLength=s.length()-start;
        if(substringLength<=MAX_PREFIX_LENGTH) {
            prefix.append(start==0 ? s : s.substring(start));
        } else {
            int limit=start+MAX_PREFIX_LENGTH-4;
            if(Character.isHighSurrogate(s.charAt(limit-1))) {
                // remove lead surrogate from the end of the prefix
                --limit;
            }
            prefix.append(s, start, limit).append(" ...");
        }
        return prefix.append("\"").toString();
    }
1291551
private int getConstraintIndex(int colIndex) {

        for (int i = 0; i < imColIndex.length; i++) {
            for (int j = 0; j < imColIndex[i].length; j++) {
                if (colIndex == imColIndex[i][j]) {
                    return i;
                }    // end of if (col == imColIndex[i][j])
            }        // end of for (int j=0; j<imColIndex[i].length; j++)
        }            // end of for (int i=0; i<imColIndex.length; i++)

        return -1;
    }
752233
char[] getChars() {
    if (tc.isEntryEnabled())
      tc.entry(this,cclass, "getChars");
    char[] ans;
    if (prefixDone)
      ans = (char[]) pattern.getSuffix().items[next--];
    else
      ans = (char[]) pattern.getPrefix().items[next++];
    if (tc.isEntryEnabled())
      tc.exit(this,cclass, "getChars", new String(ans));
    return ans;
  }
163048
public void getChars(int start, int end, char[] buffer, int index) {
		sb.getChars(start, end, buffer, index);
	}
155247
public char getToken() {
    int index = getPosition();
    String document = getDocument();
    return index >= document.length() ? NodewalkerCodec.END_OF_STRING : document.charAt(index);
  }
89093
public Result<V>[] getMatches(String lookup, int limit) {
        int strLen = lookup.length();
        char[] chars = new char[strLen + 1];
        lookup.getChars(0, strLen, chars, 0);
        chars[strLen] = '\uffff';
        
        List resultList = new ArrayList();
        fillMatchResults(chars, limit, resultList);

        return (Result[])resultList.toArray(new Result[resultList.size()]);
    }