//
//  GSObjectHelper.h
//  GlyphsCore
//
//  Created by Florian Pircher on 18.09.23.
//  Copyright © 2023 schriftgestaltung.de. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/// Returns a distinct set of parent objects of the given objects.
///
/// Each object of `objects` must respond to `-parent`. If a parent of `nil` returned, the parent is ignored.
///
/// Note that you can iterate over the returned `NSHashTable` directly instead of converting it to an array first as it holds a strong reference to the parent objects.
///
/// Uniqueness of the parent objects is based on their pointer identity; `-isEqual:` and `-hash` are not used.
///
/// Returns `nil` if `objects` is `nil` to fit along Objective-C message sending semantics.
NSHashTable * _Nullable GSDistinctParentsOfObjects(_Nullable id<NSFastEnumeration> objects);

/// Same as `GSDistinctParentsOfObjects`, but only input objects of the given class are considered; any other objects are ignored.
NSHashTable * _Nullable GSDistinctParentsOfObjectsOfClass(_Nullable id<NSFastEnumeration> objects, Class _Nullable filterClass);

NS_ASSUME_NONNULL_END
