Files
swift-collections/Sources/_CollectionsTestSupport/Utilities/SortedCollectionAPIChecker.swift
T
Karoy Lorentey 51a1554f89 Introduce _UniqueCollection & _SortedCollection
These marker-like protocols will allow certain
generic operations to get a performance boost
if the passed-in value happens to be guaranteed
to contain unique elements or to be sorted.

Also, review API checker protocols for Sets and
sorted collections and adjust things as needed.

BitSet gains custom implementations for min()
and max() as part of these improvements.
2022-10-19 01:40:06 -07:00

30 lines
1.1 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2022 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
import _CollectionsUtilities
/// This protocol simply lists Collection/Sequence extensions that ought to be
/// customized for sorted collections.
///
/// Conforming to this protocol admittedly doesn't do much, as the default
/// implementations already exist for most of these requirements
/// (but they aren't doing the right thing).
public protocol SortedCollectionAPIChecker: Collection, _SortedCollection
where Element: Comparable {
// This one actually does not come with a default implementation.
func sorted() -> Self
// These are also defined on `Sequence`, but the default implementation does
// a linear search, which isn't what we want.
func min() -> Element?
func max() -> Element?
}