//
//  NSArrayHelpers.h
//  GlyphsCore
//
//  Created by Georg Seifert on 18.08.12.
//  Copyright (c) 2012 schriftgestaltung.de. All rights reserved.
//

@interface NSArray<ObjectType> (Helpers)

- (NSArray *)filteredArrayUsingBlock:(BOOL (^)(id elt))filterBlock;

/// Returns a Boolean value indicating whether every element satisfies a given predicate.
///
/// Based on the Swift function: <https://developer.apple.com/documentation/swift/array/allsatisfy(_:)>
- (BOOL)allSatisfy:(BOOL (NS_NOESCAPE ^)(ObjectType))predicate;
/// Returns a Boolean value indicating whether the array contains an element that satisfies the given predicate.
///
/// Based on the Swift function: <https://developer.apple.com/documentation/swift/array/contains(where:)>
- (BOOL)containsWhere:(BOOL (NS_NOESCAPE ^)(ObjectType))predicate;
/// Returns a Boolean value indicating whether this array and another array contain equivalent elements in the same order, using the given predicate as the equivalence test.
///
/// Based on the Swift function: <https://developer.apple.com/documentation/swift/slice/elementsequal(_:by:)>
- (BOOL)elementsEqual:(NSArray *)other by:(BOOL (NS_NOESCAPE ^)(ObjectType, id))areEquivalent;

- (NSUInteger)countOfObjectsMatchingBlock:(BOOL (^)(id elt))filterBlock;

- (NSUInteger)countOfObjectsWithOptions:(NSEnumerationOptions)options matchingBlock:(BOOL (^)(id elt))filterBlock;

- (NSUInteger)countOfObjectsMatchingPredicate:(NSPredicate *)predicate;

- (NSUInteger)countOfObjectsWithOptions:(NSEnumerationOptions)options matchingPredicate:(NSPredicate *)predicate;

- (NSArray *)distinctValueForKey:(NSString *)key;

- (NSArray *)allCombinationsKeepOrder:(BOOL)keepOrder;

- (BOOL)writeAsOldstylePropertyList:(NSString *)filePath error:(out NSError **)error;

// shortcut to sortedArrayUsingSelector:@selector(compare:)
- (NSArray *)sorted;

- (void)makeObjectsPerformSelectorInParallel:(SEL)aSelector withObject:(id)arg;

- (void)enumerateObjectsInParallelUsingBlock:(void NS_NOESCAPE (^)(id obj, NSUInteger idx, BOOL* stop))block;

- (BOOL)isSortedComparator:(NSComparator NS_NOESCAPE)cmptr;

@end

@interface NSMutableArray (Reverse)

- (void)reverse;

@end

@interface NSMutableArray (FullSort)

- (void)fullSort:(NSComparator)comparator;

@end
