Instance Method インスタンスメソッド

inverseDifference

Calculate the difference between two objects in the reverse direction of comparison. 2つのオブジェクトの間の差異を比較の逆方向に計算します。

Declaration 宣言

- (instancetype)inverseDifference;

Return Value 戻り値

A copy of the receiver with all removals changed to insertions (and vice versa). 全ての除去が挿入へと変わった状態でのレシーバのコピー(逆もまた同じ)。

Discussion 議論

Applying a difference to an ordered collection and then applying the inverse difference results in the original ordered collection: ある差異をある順序コレクションに適用して、それからその逆の差異を適用することは、元の順序コレクションという結果になります:


NSArray *original = @[@"1", @"2"];
NSArray *modified = [original arrayByAddingObject:@"3"];


NSOrderedCollectionDifference *diff = [modified differenceFromArray:original];


NSArray *updated = [original arrayByApplyingDifference:diff];
// updated == [@"1", @"2", @"3"] == modified


NSOrderedCollectionDifference *inverse = [diff inverseDifference];


updated = [updated arrayByApplyingDifference:inverse];
// updated == [@"1", @"2"] == original