`index` stores the character number we are currently at while `length` is a constant All of the gobbles below will modify `index` as we move along
549017
function() {
        var test = gobbleBinaryExpression(),
          consequent,
          alternate;
        gobbleSpaces();
        if (exprICode(index) === QUMARK_CODE) {
          // Ternary expression: test ? consequent : alternate
          index++;
          consequent = gobbleExpression();
          if (!consequent) {
            throwError("Expected expression", index);
          }
          gobbleSpaces();
          if (exprICode(index) === COLON_CODE) {
            index++;
            alternate = gobbleExpression();
            if (!alternate) {
              throwError("Expected expression", index);
            }
            return {
              type: code.CONDITIONAL_EXP,
              test: test,
              consequent: consequent,
              alternate: alternate
            };
          } else {
            throwError("Expected :", index);
          }
        } else {
          return test;
        }
      }
51880
def characters(self, numberOfCharacters):
        """"""
        return self.code[self.index:self.index + numberOfCharacters]
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);
    }
  }
1202453
public static char idx( String str, int index ) {
        int i = calculateIndex( str.length(), index );

        char c = str.charAt( i );
        return c;
    }
1018419
public int indexOf(BinaryString subStr, int start) {
		ensureMaterialized();
		subStr.ensureMaterialized();
		if (subStr.sizeInBytes == 0) {
			return 0;
		}
		if (inFirstSegment()) {
			// position in byte
			int byteIdx = 0;
			// position is char
			int charIdx = 0;
			while (byteIdx < sizeInBytes && charIdx < start) {
				byteIdx += numBytesForFirstByte(getByteOneSegment(byteIdx));
				charIdx++;
			}
			do {
				if (byteIdx + subStr.sizeInBytes > sizeInBytes) {
					return -1;
				}
				if (SegmentsUtil.equals(segments, offset + byteIdx,
					subStr.segments, subStr.offset, subStr.sizeInBytes)) {
					return charIdx;
				}
				byteIdx += numBytesForFirstByte(getByteOneSegment(byteIdx));
				charIdx++;
			} while (byteIdx < sizeInBytes);

			return -1;
		} else {
			return indexOfSlow(subStr, start);
		}
	}
1311075
function (index, item) {
        if (index !== this.length) {
            validateListIndex(this, index);
        }

        var len = ++this.length;

        while (len-- > index) {
            this[len] = this[len - 1];
        }

        this[index] = item;
    }
954185
private boolean updateTrgPic(int index) {
		SubPicture picSrc = subtitleStream.getSubPicture(index);
		SubPicture picTrg = subPictures[index];
		double scaleX = (double) picTrg.getWidth() / picSrc.getWidth();
		double scaleY = (double) picTrg.getHeight() / picSrc.getHeight();
		double fx;
		double fy;
		if (configuration.getApplyFreeScale()) {
			fx = configuration.getFreeScaleFactorX();
			fy = configuration.getFreeScaleFactorY();
		} else {
			fx = 1.0;
			fy = 1.0;
		}

		int wOld = picTrg.getImageWidth();
		int hOld = picTrg.getImageHeight();
		int wNew = (int) (picSrc.getImageWidth() * scaleX * fx + 0.5);
		if (wNew < MIN_IMAGE_DIMENSION) {
			wNew = picSrc.getImageWidth();
		} else if (wNew > picTrg.getWidth()) {
			wNew = picTrg.getWidth();
		}
		int hNew = (int) (picSrc.getImageHeight() * scaleY * fy + 0.5);
		if (hNew < MIN_IMAGE_DIMENSION) {
			hNew = picSrc.getImageHeight();
		} else if (hNew > picTrg.getHeight()) {
			hNew = picTrg.getHeight();
		}
		picTrg.setImageWidth(wNew);
		picTrg.setImageHeight(hNew);
		if (wNew != wOld) {
			int xOfs = (int) (picSrc.getXOffset() * scaleX + 0.5);
			int spaceSrc = (int) ((picSrc.getWidth() - picSrc.getImageWidth())
					* scaleX + 0.5);
			int spaceTrg = picTrg.getWidth() - wNew;
			xOfs += (spaceTrg - spaceSrc) / 2;
			if (xOfs < 0) {
				xOfs = 0;
			} else if (xOfs + wNew > picTrg.getWidth()) {
				xOfs = picTrg.getWidth() - wNew;
			}
			picTrg.setOfsX(xOfs);
		}
		if (hNew != hOld) {
			int yOfs = (int) (picSrc.getYOffset() * scaleY + 0.5);
			int spaceSrc = (int) ((picSrc.getHeight() - picSrc.getImageHeight())
					* scaleY + 0.5);
			int spaceTrg = picTrg.getHeight() - hNew;
			yOfs += (spaceTrg - spaceSrc) / 2;
			if (yOfs + hNew > picTrg.getHeight()) {
				yOfs = picTrg.getHeight() - hNew;
			}
			picTrg.setOfsY(yOfs);
		}
		// was image cropped?
		return (wNew != wOld) || (hNew != hOld);
	}
978943
long prevSetBit(long index) {
		assert index >= 0 && index < numBits : "index=" + index + " numBits=" + numBits;
		int i = (int) (index >> 6);
		final int subIndex = (int) (index & 0x3f); // index within the word
		long word = (bits[i] << (63 - subIndex)); // skip all the bits to the
													// left of index

		if (word != 0) {
			return (i << 6) + subIndex - Long.numberOfLeadingZeros(word); // See
																			// LUCENE-3197
		}

		while (--i >= 0) {
			word = bits[i];
			if (word != 0) {
				return (i << 6) + 63 - Long.numberOfLeadingZeros(word);
			}
		}

		return -1;
	}
217418
function trimmedRightIndex(string) {
    var index = string.length;
    while (index--) {
      var c = string.charCodeAt(index);
      if (!((c <= 160 && (c >= 9 && c <= 13) || c == 32 || c == 160) || c == 5760 || c == 6158 ||
          (c >= 8192 && (c <= 8202 || c == 8232 || c == 8233 || c == 8239 || c == 8287 || c == 12288 || c == 65279)))) {
        break;
      }
    }
    return index;
  }
1336031
private void recordIndex(int index) {
        stateLock.writeLock().lock();
        try {
            int insertionPoint = -Arrays.binarySearch(effectiveIndex, index) - 1;
            System.arraycopy(effectiveIndex, insertionPoint, effectiveIndex, insertionPoint + 1, effectiveIndex.length - insertionPoint - 1);
            effectiveIndex[insertionPoint] = index;
        } finally {
            stateLock.writeLock().unlock();
        }
    }
848106
function(item, index) {
                var n = this.length,
                        i = ~~index
                if (i < 0)
                    i += n
                for (; i < n; i++)
                    if (this[i] === item)
                        return i
                return -1
            }
370524
@Override
	public int lookupIndex(String str) {
		int ret = data.get(str);
		if (ret ==-1 && !frozen)	{
			ret = index.size();
			data.put(str, ret);
			index.put(ret, str);
		}
		return ret;
	}
696562
private void checkIndex(int length) {
        if (maxLength == Integer.MAX_VALUE && knownLength < length)
            knownLength = length;
        else if (length < 0 || length >= maxLength)
            throw new IllegalArgumentException("Length must be non negative " +
                    "and less than the maximum length");
    }
528895
public int prevSetBit(int index) {
        int i = index >> 6;
        final int subIndex;
        long word;
        if (i >= wlen) {
            i = wlen - 1;
            if (i < 0) return -1;
            subIndex = 63;  // last possible bit
            word = bits[i];
        } else {
            if (i < 0) return -1;
            subIndex = index & 0x3f;  // index within the word
            word = (bits[i] << (63-subIndex));  // skip all the bits to the left of index
        }

        if (word != 0) {
            return (i << 6) + subIndex - Long.numberOfLeadingZeros(word); // See LUCENE-3197
        }

        while (--i >= 0) {
            word = bits[i];
            if (word !=0 ) {
                return (i << 6) + 63 - Long.numberOfLeadingZeros(word);
            }
        }

        return -1;
    }
859400
private static int _indexOf(@Nonnull String s, char ch) {
        int idx = s.indexOf(ch);
        if (idx<0)  return s.length();
        return idx;
    }
1216098
private int findFrom(char c, int index) {
        int currentIdx = index;
        while (currentIdx < buffer.length()) {
            if (buffer.get(currentIdx) == c) {
                return currentIdx;
            }
            currentIdx++;
        }
        return -1;
    }
963621
def stringIndex(self, string):
        
        if string in self.table:
            return self.table[string]
        else:
            result = self.current_index
            self.table[string] = result
            self.current_index += self.c_strlen(string)
            return result