Creates a "delta clone" of this Map, where only the differences are
represented.
179075
public CollectionValuedMap<K, V> deltaClone() {
    CollectionValuedMap<K, V> result = new CollectionValuedMap<K, V>(null, cf, true);
    result.map = new DeltaMap<K, Collection<V>>(this.map);
    return result;
  }
174197
def diff(a, b):
        
        delta = diff(a, b)
        if not a:
            return delta
        for item in delta:
            if isinstance(a[item], list):
                if delta[item] == []:
                    delta[item] = {JSONUtils.DIFF_DELETE : a[item]}
                elif isinstance(delta[item], dict):
                    for key in delta[item].keys():
                        if str(key) == JSONUtils.DIFF_DELETE:
                            delta_upd = {JSONUtils.DIFF_DELETE : []}
                            for i in delta[item][key]:
                                delta_upd[JSONUtils.DIFF_DELETE].append(a[item][i])
                                delta[item] = delta_upd
        return delta
866000
public void makeIndexDeltas(int[] indices) {
        assert indices.length % 3 == 0;

        for (int i = indices.length / 3 - 1; i >= 0; --i) {
            // Step 1: Calculate delta from second triangle index to the previous
            // second triangle index, if the previous triangle shares the same first
            // index, otherwise calculate the delta to the first triangle index
            if ((i >= 1) && (indices[i * 3] == indices[(i - 1) * 3])) {
                indices[i * 3 + 1] -= indices[(i - 1) * 3 + 1];
            } else {
                indices[i * 3 + 1] -= indices[i * 3];
            }

            // Step 2: Calculate delta from third triangle index to the first triangle
            // index
            indices[i * 3 + 2] -= indices[i * 3];

            // Step 3: Calculate derivative of the first triangle index
            if (i >= 1) {
                indices[i * 3] -= indices[(i - 1) * 3];
            }
        }
    }
952842
private <K, V> DiffHistoricalTypeState<K, V> createTypeState(Map<K, V> from, Map<K, V> to, boolean isGroupOfObjects) {
        int newCounter = 0;
        int diffCounter = 0;
        int deleteCounter = 0;

        for(K key : from.keySet()) {
            V toValue = to.get(key);

            if(toValue == null) {
                deleteCounter++;
            } else {
                V fromValue = from.get(key);

                if(!checkEquality(toValue, fromValue, isGroupOfObjects)) {
                    diffCounter++;
                }
            }
        }

        for(K key : to.keySet()) {
            if(!from.containsKey(key)) {
                newCounter++;
            }
        }

        OpenAddressingArraySet<K> newSet = new OpenAddressingArraySet<K>();
        OpenAddressingHashMap<K, V> diffMap = new OpenAddressingHashMap<K, V>();
        OpenAddressingHashMap<K, V> deleteMap = new OpenAddressingHashMap<K, V>();

        newSet.builderInit(newCounter);
        diffMap.builderInit(diffCounter);
        deleteMap.builderInit(deleteCounter);

        newCounter = diffCounter = deleteCounter = 0;

        for(K key : from.keySet()) {
            V fromValue = from.get(key);
            V toValue = to.get(key);

            if(toValue == null) {
                deleteMap.builderPut(deleteCounter++, key, fromValue);
            } else {
                if(!checkEquality(toValue, fromValue, isGroupOfObjects)) {
                    diffMap.builderPut(diffCounter++, key, fromValue);
                }
            }
        }

        for(K key : to.keySet()) {
            if(!from.containsKey(key)) {
                newSet.builderSet(newCounter++, key);
            }
        }

        newSet.builderFinish();
        diffMap.builderFinish();
        deleteMap.builderFinish();

        return new DiffHistoricalTypeState<K, V>(newSet, diffMap, deleteMap);
    }
1101284
public static DiffSet diffSet(Map<String, Object> introspectionOld, Map<String, Object> introspectionNew) {
        return new DiffSet(introspectionOld, introspectionNew);
    }
7850
public static <E> Set<E> difference(Set<? extends E> s1, Set<? extends E> s2) {
      Set<E> copy1 = new HashSet<>(s1);
      copy1.removeAll(new HashSet<>(s2));
      return copy1;
   }
694118
@SuppressWarnings("unchecked")
    public static NumberList delta(Map<String, Object> currentMap, NumberList previousMap) {
        return delta(currentMap, (Map)previousMap.numbers);
    }
636098
public static <T> void dumpUnchanged(Iterable<Difference<T>> diffs) {
		for(Difference<T> diff: diffs) {
			if(Difference.Type.UNCHANGED.equals(diff.getType())) {
				System.out.println(diff);
			}
		}
	}
350414
private Deque<MutablePair<DeltaType, Object>> combineDeltas(
      LinkedList<MutablePair<DeltaType, Object>> deltas) {
    if (deltas.size() < 2) {
      return deltas;
    }
    int size = deltas.size();
    MutablePair<DeltaType, Object> d1 = deltas.peekLast();
    MutablePair<DeltaType, Object> d2 = deltas.get(size - 2);
    MutablePair<DeltaType, Object> out = isDuplicate(d1, d2);
    if (out != null) {
      Deque<MutablePair<DeltaType, Object>> newDeltas = new LinkedList<>();
      newDeltas.addAll(deltas.subList(0, size - 2));
      newDeltas.add(out);
      return newDeltas;
    }
    return deltas;
  }
16271
static Map<String, Object> sumOfDelta(Map<String, Object> state, Map<String, Object> delta) {
        InstanceKey instanceId = (InstanceKey) delta.get("InstanceKey");
        if (instanceId == null) {
            throw new RuntimeException("InstanceKey can not be null");
        }
        for (String key : delta.keySet()) {
            Object existing = state.get(key);
            Object current = delta.get(key);
            if (current instanceof Number) {
                if (existing == null) {
                    existing = 0;
                }
                Number v = (Number) existing;
                Number d = (Number) delta.get(key);
                state.put(key, v.longValue() + d.longValue());
            } else if (current instanceof NumberList) {
                if (existing == null) {
                    state.put(key, current);
                } else {
                    state.put(key, ((NumberList) existing).sum((NumberList) current));
                }
            } else {
                Object o = delta.get(key);
                if (o instanceof String[]) {
                    String[] vs = (String[]) o;
                    if (vs.length == 1) {
                        Object previousAggregateString = state.get(key);
                        if (previousAggregateString instanceof AggregateString) {
                            state.put(key, ((AggregateString) previousAggregateString).update(null, vs[0], instanceId));
                        } else {
                            state.put(key, AggregateString.create(vs[0], instanceId));
                        }
                    } else {
                        // it should always be AggregateString here since that's all we add above
                        AggregateString pas = (AggregateString) state.get(key);
                        state.put(key, pas.update(vs[0], vs[1], instanceId));
                    }
                } else {
                    state.put(key, String.valueOf(o));
                }

            }
        }
        return state;
    }
1274054
function(delta) {
        return new $.Rect(
            this.x + delta.x,
            this.y + delta.y,
            this.width,
            this.height,
            this.degrees);
    }
1357518
function copy(product, left) {
  product.rows = parseInt(left.rows);
  product.columns = parseInt(left.columns);
  product.weights = left.weights.slice(0);
  product.deltas = left.deltas.slice(0);
}
684583
def copy(self):
        
        # new objects are constructed for each, so we just need to pass them in
        return BinaryQuadraticModel(self.linear, self.quadratic, self.offset, self.vartype, **self.info)
964750
def clone(self, d):
        
        return Desinence(d.grq(), d.morphoNum(), d.numRad(), self)
605902
private Delta<E> toDelta(difflib.Delta<E> delta) throws DiffException
    {
        Delta<E> newDelta;

        switch (delta.getType()) {
            case CHANGE:
                newDelta = new ChangeDelta<E>(delta.getOriginal(), delta.getRevised());
                break;
            case DELETE:
                newDelta = new DeleteDelta<E>(delta.getOriginal(), delta.getRevised());
                break;
            case INSERT:
                newDelta = new InsertDelta<E>(delta.getOriginal(), delta.getRevised());
                break;
            default:
                throw new DiffException(String.format("Failed to convert [%s] info [%s]. Unknown type [%s]", delta
                    .getClass().getName(), Delta.class.getName(), delta.getType().toString()));
        }

        return newDelta;
    }
497744
def tick_deltas
      unless @delta.empty?
        merge_to_db(@delta)
        @tick_delta.concat(@delta.values) if accumulate_tick_deltas
        @delta.clear
      end
      unless @new_delta.empty?
        # We allow @new_delta to contain duplicates but eliminate them here. We
        # can't just allow duplicate delta tuples because that might cause
        # spurious infinite delta processing loops.
        @new_delta.reject! {|key, val| self[key] == val}

        @delta = @new_delta
        @new_delta = {}
      end
      return !(@delta.empty?)
    end
1261616
public static <K, V> Map<K, V> updateMap(final Map<K, V> original, MapDifference<K, V> diff) throws MergeException {
        Map<K, V> result = new HashMap<K, V>(original);
        if (diff.areEqual()) {
            return result;
        }
        for (Entry<K, V> entry : diff.entriesOnlyOnLeft().entrySet()) {
            V originalValue = original.get(entry.getKey());
            if (ObjectUtils.equals(originalValue, entry.getValue())) {
                result.remove(entry.getKey());
            }
        }
        for (Entry<K, V> entry : diff.entriesOnlyOnRight().entrySet()) {
            K key = entry.getKey();
            if (original.containsKey(key)) {
                if (ObjectUtils.notEqual(original.get(key), entry.getValue())) {
                    throw new MergeException(String.format(
                        "tried to introduce a new value, but it was already there: %s (%s,%s)",
                        key, original.get(key), entry.getValue()));
                }
            }
            result.put(entry.getKey(), entry.getValue());
        }
        for (Entry<K, ValueDifference<V>> entry : diff.entriesDiffering().entrySet()) {
            K key = entry.getKey();
            V originalValue = original.get(entry.getKey());
            if (ObjectUtils.equals(originalValue, entry.getValue().leftValue())) {
                // Map changed in diff only
                result.put(key, entry.getValue().rightValue());
            } else if (ObjectUtils.equals(originalValue, entry.getValue().rightValue())) {
                // Diff would change value to value already in original Map
                result.put(key, originalValue);
            } else {
                // Merge conflict, got 3 different Values
                String errorMessage =
                    String
                        .format(
                            "Changes could not be applied, because original value differes from left-side of the"
                                    + "MapDifference: %s (%s,%s)", entry.getKey(), original.get(entry.getKey()),
                            entry.getValue());
                throw new MergeException(errorMessage);
            }
        }
        return result;
    }