//
//  GSCompareLists.h
//  MergeGlyphs
//
//  Created by Georg Seifert on 20.05.16.
//  Copyright © 2016 Georg Seifert. All rights reserved.
//

NSArray *GSCompareLists(NSArray *firstCollection, NSArray *secondCollection);

@interface LongestCommonSubitemResult : NSObject
@property (nonatomic) bool success;
@property (nonatomic) int positionInFirst;
@property (nonatomic) int positionInSecond;
@property (nonatomic) int length;
@end

NSInteger GSLevenshteinDistance(NSString *stringA, NSString *stringB);

void GSAlignAllStringArrays(NSArray<NSMutableArray<NSString *> *> *arrays);

typedef NS_ENUM(uint8_t, GSMergeState) {
	GSMergeStateInAll = 0,	// key present in every list
	GSMergeStateMulti = 1	// key present in some but not all lists (conflict -> show Multi)
};

@interface GSMergeItem : NSObject

- (instancetype)initWithObject:(id)object key:(NSString *)key;

- (instancetype)initWithObjects:(NSMutableArray *)objects key:(NSString *)key;

@property(nonatomic, copy) NSString *key;				// comparison key
@property(nonatomic, strong) NSMutableArray *objects;	// aggregated payload objects (order preserved, deduped)
@property(nonatomic, assign) GSMergeState mergeState;	// computed after merge

@end

NSArray<GSMergeItem *> *GSMergeListsOfMergeItems(NSArray<NSArray<GSMergeItem *> *> *lists);
