difflib.Delta.applyTo()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.2k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中difflib.Delta.applyTo()方法的一些代码示例,展示了Delta.applyTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Delta.applyTo()方法的具体详情如下:
包路径:difflib.Delta
类名称:Delta
方法名:applyTo

Delta.applyTo介绍

[英]Applies this delta as the patch for a given target
[中]将此增量应用为给定目标的修补程序

代码示例

代码示例来源:origin: com.googlecode.java-diff-utils/diffutils

  1. /**
  2. * Apply this patch to the given target
  3. * @return the patched text
  4. * @throws PatchFailedException if can't apply patch
  5. */
  6. public List<T> applyTo(List<T> target) throws PatchFailedException {
  7. List<T> result = new LinkedList<T>(target);
  8. ListIterator<Delta<T>> it = getDeltas().listIterator(deltas.size());
  9. while (it.hasPrevious()) {
  10. Delta<T> delta = (Delta<T>) it.previous();
  11. delta.applyTo(result);
  12. }
  13. return result;
  14. }

代码示例来源:origin: com.custardsource.dybdob/java-diff-utils-copy

  1. /**
  2. * Apply this patch to the given target
  3. * @param target
  4. * @return the patched text
  5. * @throws PatchFailedException if can't apply patch
  6. */
  7. public List<?> applyTo(List<?> target) throws PatchFailedException {
  8. List<Object> result = new LinkedList<Object>(target);
  9. ListIterator<Delta> it = getDeltas().listIterator(deltas.size());
  10. while (it.hasPrevious()) {
  11. Delta delta = (Delta) it.previous();
  12. delta.applyTo(result);
  13. }
  14. return result;
  15. }

相关文章