Replace the segments of this section starting at the given index with the given replacement segments

@param index
@param replacement
@return
191320
public IPv6AddressSection replace(int index, IPv6AddressSection replacement) {
		return replace(index, index + replacement.getSegmentCount(), replacement, 0, replacement.getSegmentCount());
	}
765732
public Expression2 substitute(int index, String newConstantExpression) {
    return substitute(index, Expression2.constant(newConstantExpression));
  }
1286756
@Private Location lookup(int index) {
    int size = lineBreakIndices.size();
    if (size == 0) return location(0, index);
    int lineNumber = binarySearch(lineBreakIndices, index);
    if (lineNumber == 0) return location(0, index);
    int previousBreak = lineBreakIndices.get(lineNumber - 1);
    return location(lineNumber, index - previousBreak - 1);
  }
36760
public Tuple3<ReadOnlyStyledDocument<PS, SEG, S>, RichTextChange<PS, SEG, S>, MaterializedListModification<Paragraph<PS, SEG, S>>> replace(
            Replacement<PS, SEG, S> replacement) {
        return replace(replacement.getStart(), replacement.getEnd(), replacement.getDocument());
    }
1344627
public Segment truncate(long index) {
    assertSegmentOpen();
    Assert.index(index >= manager.commitIndex(), "cannot truncate committed index");

    long offset = relativeOffset(index);
    long lastOffset = offsetIndex.lastOffset();

    long diff = Math.abs(lastOffset - offset);
    skip = Math.max(skip - diff, 0);

    if (offset < lastOffset) {
      long position = offsetIndex.truncate(offset);
      buffer.position(position)
        .zero(position)
        .flush();
      termIndex.truncate(offset);
    }
    return this;
  }
1076406
@Override
	public void replaceChildren(int startChildIndex, int stopChildIndex, Object t) {
		/*
		System.out.println("replaceChildren "+startChildIndex+", "+stopChildIndex+
						   " with "+((BaseTree)t).toStringTree());
		System.out.println("in="+toStringTree());
		*/
		if ( children==null ) {
			throw new IllegalArgumentException("indexes invalid; no children in list");
		}
		int replacingHowMany = stopChildIndex - startChildIndex + 1;
		int replacingWithHowMany;
		BaseTree newTree = (BaseTree)t;
		List<Object> newChildren;
		// normalize to a list of children to add: newChildren
		if ( newTree.isNil() ) {
			newChildren = newTree.children;
		}
		else {
			newChildren = new ArrayList<Object>(1);
			newChildren.add(newTree);
		}
		replacingWithHowMany = newChildren.size();
		int numNewChildren = newChildren.size();
		int delta = replacingHowMany - replacingWithHowMany;
		// if same number of nodes, do direct replace
		if ( delta == 0 ) {
			int j = 0; // index into new children
			for (int i=startChildIndex; i<=stopChildIndex; i++) {
				BaseTree child = (BaseTree)newChildren.get(j);
				children.set(i, child);
				child.setParent(this);
				child.setChildIndex(i);
                j++;
            }
		}
		else if ( delta > 0 ) { // fewer new nodes than there were
			// set children and then delete extra
			for (int j=0; j<numNewChildren; j++) {
				children.set(startChildIndex+j, newChildren.get(j));
			}
			int indexToDelete = startChildIndex+numNewChildren;
			for (int c=indexToDelete; c<=stopChildIndex; c++) {
				// delete same index, shifting everybody down each time
				children.remove(indexToDelete);
			}
			freshenParentAndChildIndexes(startChildIndex);
		}
		else { // more new nodes than were there before
			// fill in as many children as we can (replacingHowMany) w/o moving data
			for (int j=0; j<replacingHowMany; j++) {
				children.set(startChildIndex+j, newChildren.get(j));
			}
			//int numToInsert = replacingWithHowMany-replacingHowMany;
			for (int j=replacingHowMany; j<replacingWithHowMany; j++) {
				children.add(startChildIndex+j, newChildren.get(j));
			}
			freshenParentAndChildIndexes(startChildIndex);
		}
		//System.out.println("out="+toStringTree());
	}
1327419
public List<String> replaceRunOnWords(final String original) {
    final List<String> candidates = new ArrayList<String>();
    String wordToCheck = original;
    if (!dictionaryMetadata.getInputConversionPairs().isEmpty()) {
      wordToCheck = DictionaryLookup.applyReplacements(original, dictionaryMetadata.getInputConversionPairs());
    }
    if (!isInDictionary(wordToCheck) && dictionaryMetadata.isSupportingRunOnWords()) {
      for (int i = 1; i < wordToCheck.length(); i++) {
        // chop from left to right
        final CharSequence firstCh = wordToCheck.subSequence(0, i);
        if (isInDictionary(firstCh) && isInDictionary(wordToCheck.subSequence(i, wordToCheck.length()))) {
          if (dictionaryMetadata.getOutputConversionPairs().isEmpty()) {
            candidates.add(firstCh + " " + wordToCheck.subSequence(i, wordToCheck.length()));
          } else {
            candidates.add(DictionaryLookup.applyReplacements(firstCh + " " + wordToCheck.subSequence(i, wordToCheck.length()),
                dictionaryMetadata.getOutputConversionPairs()).toString());
          }
        }
      }
    }
    return candidates;
  }
14417
public static <T> PositionFactory<Iterable<? extends T>, T> atIndex(final int index) {
        return new PositionFactory<Iterable<? extends T>, T>(index) {

            @Override
            public String toString() {
                return String.format("Element [%s]", index);
            }

            @Override
            protected <P> Type evaluateElementType(Position<P> parentPosition) {
                return TypeUtils.getTypeArguments(parentPosition.getType(), Iterable.class)
                    .get(Iterable.class.getTypeParameters()[0]);
            }
        };
    }
1102846
@Override
	public void add(int index, ST segment) {
		if (index < 0 || index > this.segmentList.size()) {
			throw new IndexOutOfBoundsException();
		}
		// The path is empty, so that the segment is the first one.
		if (this.segmentList.isEmpty()) {
			if (this.segmentList.add(segment)) {
				this.startingPoint = segment.getBeginPoint();
				this.endingPoint = segment.getEndPoint();
				this.length += segment.getLength();
				return;
			}
			throw new IllegalArgumentException();
		}

		// Detect the candidates to the connection
		final PT candidate;

		this.isReversable = false;

		if (index < this.segmentList.size()) {
			candidate = getStartingPointFor(index);
		} else {
			candidate = this.endingPoint;
		}

		// Check the connection validity
		if (candidate != null) {
			final PT first = segment.getBeginPoint();
			final PT last = segment.getEndPoint();
			if (index == 0 && (candidate.equals(first) || candidate.equals(last))) {
				this.segmentList.add(0, segment);
				this.startingPoint = segment.getOtherSidePoint(this.startingPoint);
				this.length += segment.getLength();
				return;
			} else if (index == this.segmentList.size() && (candidate.equals(first) || candidate.equals(last))) {
				this.segmentList.add(segment);
				this.endingPoint = segment.getOtherSidePoint(this.endingPoint);
				this.length += segment.getLength();
				return;
			} else if (candidate.equals(first) || candidate.equals(last)) {
				this.segmentList.add(index, segment);
				this.length += segment.getLength();
				return;
			}
		}

		throw new IllegalArgumentException();
	}
567085
protected String applyTextReplacements(Iterable<ITextReplacement> replacements) {
		ITextSegment region = getRegion();
		String input = region.getText();
		ArrayList<ITextReplacement> list = Lists.newArrayList(replacements);
		Collections.sort(list);
		int startOffset = region.getOffset();
		int lastOffset = 0;
		StringBuilder result = new StringBuilder();
		for (ITextReplacement r : list) {
			int offset = r.getOffset() - startOffset;
			result.append(input.subSequence(lastOffset, offset));
			result.append(r.getReplacementText());
			lastOffset = offset + r.getLength();
		}
		result.append(input.subSequence(lastOffset, input.length()));
		return result.toString();
	}
1153299
@Override
	@Pure
	public RoadPolyline getMapElementAt(int index) {
		final Iterator<RoadSegment> segments = this.roadNetwork.iterator();
		for (int i = 0; i < index - 1 && segments.hasNext(); ++i) {
			segments.next();
		}
		if (segments.hasNext()) {
			return (RoadPolyline) segments.next();
		}
		throw new IndexOutOfBoundsException();
	}
912557
public Expression2 substitute(int index, Expression2 newExpression) {
    Preconditions.checkArgument(index < size);
    if (index == 0) {
      return newExpression;
    } else {
      int[] parts = findSubexpression(index);
      
      Expression2 substituted = subexpressions.get(parts[0]).substitute(parts[1], newExpression);
      List<Expression2> newSubexpressions = Lists.newArrayList(subexpressions);
      newSubexpressions.set(parts[0], substituted);
      return Expression2.nested(newSubexpressions);
    }
  }
1253681
public StringGrabber replaceEnclosedIn(String startToken, String endToken, String replacement) {

		StringCropper cropper = getCropper();

		final List<StrPosition> stringEnclosedInWithDetails = cropper.getStringEnclosedInWithDetails(sb.toString(), startToken, endToken);

		final List<Integer> splitList = new ArrayList<Integer>();

		for (StrPosition sp : stringEnclosedInWithDetails) {

			int splitPointFirst = sp.startIndex - 1;
			int splitPointSecond = sp.endIndex;

			splitList.add(splitPointFirst);
			splitList.add(splitPointSecond);
		}

		final Integer[] splitIndexes = splitList.toArray(new Integer[] {});

		List<String> splitStringList = cropper.splitByIndex(sb.toString(), splitIndexes);

		final StringBuilder tempSb = new StringBuilder();

		final int strNum = splitStringList.size();

		boolean nextIsValue = false;

		int countOfReplacement = 0;

		for (int i = 0; i < strNum; i++) {

			String strPart = splitStringList.get(i);

			if (nextIsValue) {
				// position to add into replacement
				tempSb.append(replacement);

				countOfReplacement++;

				if (strPart.startsWith(endToken)) {
					// is string Blank
					tempSb.append(strPart);
				}

			} else {
				tempSb.append(strPart);
			}

			if (strPart.endsWith(startToken)) {
				nextIsValue = true;
			} else {
				nextIsValue = false;
			}

		}

		sb = tempSb;

		return StringGrabber.this;

	}
188685
public void replace(Fragment fragment) {
        manager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        manager.beginTransaction()
            .replace(containerId, fragment, indexToTag(0))
            .commit();
        manager.executePendingTransactions();
    }
640609
protected String remainder(int index) {
        if (index > this.array.length)
            return "";
        else return new String(Arrays.copyOfRange(this.array, index, this.array.length));
    }
305758
public static <T extends AbstractJaxb> void replaceDescendants(T target,
            String clazz, T replace) throws TagTypeUnmatchException {
        execute(target, null, clazz, replace);
    }
609774
public RoadSegment removeRoadSegmentAt(int index) {
		if (index >= 0) {
			int b = 0;
			for (final RoadPath p : this.paths) {
				int end = b + p.size();
				if (index < end) {
					end = index - b;
					return removeRoadSegmentAt(p, end, null);
				}
				b = end;
			}
		}
		throw new IndexOutOfBoundsException();
	}