This method merge 2 diffs ( remove then add, or vice versa ) with same value into one Move operation,
all the core logic resides here only
337710
private void introduceMoveOperation() {
        for (int i = 0; i < diffs.size(); i++) {
            Diff diff1 = diffs.get(i);

            // if not remove OR add, move to next diff
            if (!(Operation.REMOVE == diff1.getOperation() ||
                    Operation.ADD == diff1.getOperation())) {
                continue;
            }

            for (int j = i + 1; j < diffs.size(); j++) {
                Diff diff2 = diffs.get(j);
                if (!diff1.getValue().equals(diff2.getValue())) {
                    continue;
                }

                Diff moveDiff = null;
                if (Operation.REMOVE == diff1.getOperation() &&
                        Operation.ADD == diff2.getOperation()) {
                    JsonPointer relativePath = computeRelativePath(diff2.getPath(), i + 1, j - 1, diffs);
                    moveDiff = new Diff(Operation.MOVE, diff1.getPath(), relativePath);

                } else if (Operation.ADD == diff1.getOperation() &&
                        Operation.REMOVE == diff2.getOperation()) {
                    JsonPointer relativePath = computeRelativePath(diff2.getPath(), i, j - 1, diffs); // diff1's add should also be considered
                    moveDiff = new Diff(Operation.MOVE, relativePath, diff1.getPath());
                }
                if (moveDiff != null) {
                    diffs.remove(j);
                    diffs.set(i, moveDiff);
                    break;
                }
            }
        }
    }
1110458
function _merge (getKeys, a, b) {
    return reduce([a, b], function (result, source) {
        forEach(getKeys(source), function (key) {
            result[key] = source[key];
        });

        return result;
    }, {});
}
149182
function merge(prev, current, next) {
  return prev
    .concat()
    .reverse()
    .concat([current], next)
}
1084751
def _create_diff_action(diff, diff_key, key, value):

    '''
    
    '''

    if diff_key not in diff.keys():
        diff[diff_key] = {}
    diff[diff_key][key] = value
281823
static void doDifference(
            Map<String, String> left,
            Map<String, String> right,
            Map<String, String> onlyOnLeft,
            Map<String, String> onlyOnRight,
            Map<String, String> updated
    ) {
        onlyOnRight.clear();
        onlyOnRight.putAll(right);
        for (Map.Entry<String, String> entry : left.entrySet()) {
            String leftKey = entry.getKey();
            String leftValue = entry.getValue();
            if (right.containsKey(leftKey)) {
                String rightValue = onlyOnRight.remove(leftKey);
                if (!leftValue.equals(rightValue)) {
                    updated.put(leftKey, leftValue);
                }
            } else {
                onlyOnLeft.put(leftKey, leftValue);
            }
        }
    }
24636
def symmetric_difference_update(self, other):
		""""""
		other = setlist(other)
		indices_to_delete = set()
		for i, item in enumerate(self):
			if item in other:
				indices_to_delete.add(i)
		for item in other:
			self.add(item)
		self._delete_values_by_index(indices_to_delete)
1347277
public static <E> Set<E> diff(Set<E> s1, Set<E> s2) {
    Set<E> s = new HashSet<E>();
    for (E o : s1) {
      if (!s2.contains(o)) {
        s.add(o);
      }
    }
    return s;
  }
1331134
private void merge(Integer cid1, Integer cid2) {
    Collection<String> klass1 = classix.get(cid1);
    Collection<String> klass2 = classix.get(cid2);

    // if klass1 is the smaller, swap the two
    if (klass1.size() < klass2.size()) {
      Collection<String> tmp = klass2;
      klass2 = klass1;
      klass1 = tmp;

      Integer itmp = cid2;
      cid2 = cid1;
      cid1 = itmp;
    }

    // now perform the actual merge
    for (String id : klass2) {
      klass1.add(id);
      recordix.put(id, cid1);
    }

    // delete the smaller class, and we're done
    classix.remove(cid2);
  }
1061185
def merge(a, b):
    
    if isinstance(a, CONFIG_VALID) \
            and isinstance(b, CONFIG_VALID):
        # dict update
        if isinstance(a, dict) and isinstance(b, dict):
            a.update(b)
            return a
        # list update
        _a = list(a)
        for x in list(b):
            if x not in _a:
                _a.append(x)
        return _a
    if a and b:
        raise Exception("Cannot merge")
    raise NotImplementedError
930294
def dictionary_merge(a, b):
    
    for key, value in b.items():
        if key in a and isinstance(a[key], dict) and isinstance(value, dict):
            dictionary_merge(a[key], b[key])
            continue
        a[key] = b[key]
    return a
1321742
function unifiedDiff (actual, expected, formatAdd, formatRem) {
  return [
    formatAdd('+ expected'),
    formatRem('- actual'),
    ''
  ]
    .concat(
      diff.createPatch('string', actual, expected)
        .split('\n')
        .slice(4)
        .filter(function (line) {
          return line[0] === '+' || line[0] === '-'
        })
        .map(function (line) {
          return line[0] === '+' ? formatAdd(line) : formatRem(line)
        })
    )
    .join('\n')
}
459890
def _dirdiffcopyandupdate(self, dir1, dir2):
        
        self._dowork(dir1, dir2, self._copy, self._update)
1332109
void cleanupMerge(LinkedList<Change> diffs) {
        diffs.add(new Change(Operation.EQUAL, ""));  // Add a dummy entry at the end.
        ListIterator<Change> pointer = diffs.listIterator();
        int count_delete = 0;
        int count_insert = 0;
        String text_delete = "";
        String text_insert = "";
        Change thisDiff = pointer.next();
        Change prevEqual = null;
        int commonlength;
        while (thisDiff != null) {
            switch (thisDiff.operation) {
                case INSERT:
                    count_insert++;
                    text_insert += thisDiff.text;
                    prevEqual = null;
                    break;
                case DELETE:
                    count_delete++;
                    text_delete += thisDiff.text;
                    prevEqual = null;
                    break;
                case EQUAL:
                    if (count_delete + count_insert > 1) {
                        boolean both_types = count_delete != 0 && count_insert != 0;
                        // Delete the offending records.
                        pointer.previous();  // Reverse direction.
                        while (count_delete-- > 0) {
                            pointer.previous();
                            pointer.remove();
                        }
                        while (count_insert-- > 0) {
                            pointer.previous();
                            pointer.remove();
                        }
                        if (both_types) {
                            // Factor out any common prefixies.
                            commonlength = commonPrefix(text_insert, text_delete);
                            if (commonlength != 0) {
                                if (pointer.hasPrevious()) {
                                    thisDiff = pointer.previous();
                                    assert thisDiff.operation == Operation.EQUAL
                                            : "Previous diff should have been an equality.";
                                    thisDiff.text += text_insert.substring(0, commonlength);
                                    pointer.next();
                                } else {
                                    pointer.add(new Change(Operation.EQUAL,
                                                           text_insert.substring(0, commonlength)));
                                }
                                text_insert = text_insert.substring(commonlength);
                                text_delete = text_delete.substring(commonlength);
                            }
                            // Factor out any common suffixies.
                            commonlength = commonSuffix(text_insert, text_delete);
                            if (commonlength != 0) {
                                thisDiff = pointer.next();
                                thisDiff.text = text_insert.substring(text_insert.length()
                                                                      - commonlength) + thisDiff.text;
                                text_insert = text_insert.substring(0, text_insert.length()
                                                                       - commonlength);
                                text_delete = text_delete.substring(0, text_delete.length()
                                                                       - commonlength);
                                pointer.previous();
                            }
                        }
                        // Insert the merged records.
                        if (text_delete.length() != 0) {
                            pointer.add(new Change(Operation.DELETE, text_delete));
                        }
                        if (text_insert.length() != 0) {
                            pointer.add(new Change(Operation.INSERT, text_insert));
                        }
                        // Step forward to the equality.
                        thisDiff = pointer.hasNext() ? pointer.next() : null;
                    } else if (prevEqual != null) {
                        // Merge this equality with the previous one.
                        prevEqual.text += thisDiff.text;
                        pointer.remove();
                        thisDiff = pointer.previous();
                        pointer.next();  // Forward direction
                    }
                    count_insert = 0;
                    count_delete = 0;
                    text_delete = "";
                    text_insert = "";
                    prevEqual = thisDiff;
                    break;
            }
            thisDiff = pointer.hasNext() ? pointer.next() : null;
        }
        if (diffs.getLast().text.length() == 0) {
            diffs.removeLast();  // Remove the dummy entry at the end.
        }

    /*
     * Second pass: look for single edits surrounded on both sides by equalities
     * which can be shifted sideways to eliminate an equality.
     * e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
     */
        boolean changes = false;
        // Create a new iterator at the start.
        // (As opposed to walking the current one back.)
        pointer = diffs.listIterator();
        Change prevDiff = pointer.hasNext() ? pointer.next() : null;
        thisDiff = pointer.hasNext() ? pointer.next() : null;
        Change nextDiff = pointer.hasNext() ? pointer.next() : null;
        // Intentionally ignore the first and last element (don't need checking).
        while (nextDiff != null) {
            if (prevDiff.operation == Operation.EQUAL &&
                nextDiff.operation == Operation.EQUAL) {
                // This is a single edit surrounded by equalities.
                if (thisDiff.text.endsWith(prevDiff.text)) {
                    // Shift the edit over the previous equality.
                    thisDiff.text = prevDiff.text
                                    + thisDiff.text.substring(0, thisDiff.text.length()
                                                                 - prevDiff.text.length());
                    nextDiff.text = prevDiff.text + nextDiff.text;
                    pointer.previous(); // Walk past nextDiff.
                    pointer.previous(); // Walk past thisDiff.
                    pointer.previous(); // Walk past prevDiff.
                    pointer.remove(); // Delete prevDiff.
                    pointer.next(); // Walk past thisDiff.
                    thisDiff = pointer.next(); // Walk past nextDiff.
                    nextDiff = pointer.hasNext() ? pointer.next() : null;
                    changes = true;
                } else if (thisDiff.text.startsWith(nextDiff.text)) {
                    // Shift the edit over the next equality.
                    prevDiff.text += nextDiff.text;
                    thisDiff.text = thisDiff.text.substring(nextDiff.text.length())
                                    + nextDiff.text;
                    pointer.remove(); // Delete nextDiff.
                    nextDiff = pointer.hasNext() ? pointer.next() : null;
                    changes = true;
                }
            }
            prevDiff = thisDiff;
            thisDiff = nextDiff;
            nextDiff = pointer.hasNext() ? pointer.next() : null;
        }
        // If shifts were made, the diff needs reordering and another shift sweep.
        if (changes) {
            cleanupMerge(diffs);
        }
    }
692223
function merge(dest) {
  if (dest) {
    Array.prototype.slice.call(arguments, 1).forEach(function(arg) {
      Object.keys(arg).forEach(function(key) {
        dest[key] = arg[key]
      })
    })
  }

  return dest
}
251409
private int append(FA add) {
        int relocation;
        int idx;

        relocation = used;
        ensureCapacity(used + add.used);
        for (idx = 0; idx < add.used; idx++) {
            states[relocation + idx] =
                new State(add.states[idx], relocation);
        }
        used += add.used;
        return relocation;
    }
1171137
public V put(K1 key1, K2 key2, V value) {
        return getOrPutGetNew(key1).put(key2, value);
    }
267914
def dict_merge_pair(d1, d2):
    
    for key in d2:
        if key in d1 and isinstance(d1[key], dict) and \
           isinstance(d2[key], dict):
            dict_merge_pair(d1[key], d2[key])
        else:
            d1[key] = d2[key]

    return d1