KeyPathComparator
Compares elements using a KeyPath
, and a SortComparator
which compares elements of the KeyPath
s Value
type.
- iOS
- 15.0+
- macOS
- 12.0+
- tvOS
- 15.0+
- watchOS
- 8.0+
struct KeyPathComparator<Compared>
Compares elements using a KeyPath
, and a SortComparator
which compares elements of the KeyPath
s Value
type.
struct KeyPathComparator<Compared>
import FoundationInternationalization
protocol Equatable
A type that can be compared for value equality.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol Sendable
@preconcurrency protocol SortComparator<Compared> : Hashable, Sendable
A comparison algorithm for a given type.
init<Value, Comparator>(_ keyPath: any KeyPath<Compared, Value> & Sendable, comparator: Comparator) where Value == Comparator.Compared, Comparator : SortComparator
init<Value, Comparator>(_ keyPath: any KeyPath<Compared, Value?> & Sendable, comparator: Comparator) where Value == Comparator.Compared, Comparator : SortComparator
init<Value, Comparator>(_ keyPath: any KeyPath<Compared, Value> & Sendable, comparator: Comparator, order: SortOrder) where Value == Comparator.Compared, Comparator : SortComparator
init<Value, Comparator>(_ keyPath: any KeyPath<Compared, Value?> & Sendable, comparator: Comparator, order: SortOrder) where Value == Comparator.Compared, Comparator : SortComparator
init<Value>(_ keyPath: any KeyPath<Compared, Value> & Sendable, order: SortOrder = .forward) where Value : Comparable
init<Value>(_ keyPath: any KeyPath<Compared, Value?> & Sendable, order: SortOrder = .forward) where Value : Comparable
@preconcurrency let keyPath: any PartialKeyPath<Compared> & Sendable
The key path to the property to be used for comparisons.
var order: SortOrder { get set }
static func == (lhs: KeyPathComparator<Compared>, rhs: KeyPathComparator<Compared>) -> Bool
func compare(_ lhs: Compared, _ rhs: Compared) -> ComparisonResult
func hash(into hasher: inout Hasher)
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.