Add custom comparision block to array diffing category

This commit is contained in:
Levi McCallum
2016-02-01 15:31:46 -08:00
parent 9f25b54f9e
commit bd1de07c77
2 changed files with 23 additions and 5 deletions

View File

@@ -11,8 +11,19 @@
@interface NSArray (Diffing)
/**
* Uses a bottom-up memoized longest common subsequence solution to identify differences. Runs in O(mn) complexity.
* @abstract Compares two arrays, providing the insertion and deletion indexes needed to transform into the target array.
* @discussion This compares the equality of each object with `isEqual:`.
* This diffing algorithm uses a bottom-up memoized longest common subsequence solution to identify differences.
* It runs in O(mn) complexity.
*/
- (void)asdk_diffWithArray:(NSArray *)array insertions:(NSIndexSet **)insertions deletions:(NSIndexSet **)deletions;
/**
* @abstract Compares two arrays, providing the insertion and deletion indexes needed to transform into the target array.
* @discussion The `compareBlock` is used to identify the equality of the objects within the arrays.
* This diffing algorithm uses a bottom-up memoized longest common subsequence solution to identify differences.
* It runs in O(mn) complexity.
*/
- (void)asdk_diffWithArray:(NSArray *)array insertions:(NSIndexSet **)insertions deletions:(NSIndexSet **)deletions compareBlock:(BOOL (^)(id lhs, id rhs))comparison;
@end