RandomAccessCollection
extension RandomAccessCollection
extension RandomAccessCollection where Iterator.Element: AnyObject
extension RandomAccessCollection where Iterator.Element: Equatable
extension RandomAccessCollection where Element == Key
-
Undocumented
Declaration
Swift
public typealias OrderPredicate = (Iterator.Element, Iterator.Element) -> Bool -
Binary search operation for quick determination where to insert a new value into a collection that will preserve the ordering of the existing elements.
Declaration
Swift
public func insertionIndex(of value: Iterator.Element, predicate: OrderPredicate) -> IndexParameters
valuethe value to insert
predicatea closure/function that determines ordering of two elements
Return Value
index into the collection
-
Obtain the index in a collection for a given object.
Declaration
Swift
public func search(for value: Iterator.Element, predicate: OrderPredicate) -> IndexParameters
valuethe object to look for
Return Value
index of the give value or
endIndexif not found -
Binary search operation which simply determines if a given value is in the collection.
Declaration
Swift
public func contains(value: Iterator.Element, predicate: OrderPredicate) -> BoolParameters
valuethe value to look for
predicatea closure/function that determines ordering of two elements
Return Value
true if element is in the collections
-
Obtain the index in a collection for a given value.
Declaration
Swift
public func search(for value: Iterator.Element, predicate: OrderPredicate) -> IndexParameters
valuethe value to look for
Return Value
index of the give value or
endIndexif not found -
Binary search operation which simply determines if a given value is in the collection.
Declaration
Swift
public func contains(value: Iterator.Element, predicate: OrderPredicate) -> BoolParameters
valuethe value to look for
predicatea closure/function that determines ordering of two elements
Return Value
true if element is in the collections
-
Obtain the key that is touched by the given point.
Declaration
Swift
func touched(by point: CGPoint) -> Key?Parameters
pointthe location to consider
Return Value
Key instance that contains the point, or nil if none.
-
Obtain the sequence of keys that fill the given rect. Only considers the horizontal span for inclusion.
Declaration
Swift
func keySpan(for rect: CGRect) -> Self.SubSequenceParameters
rectthe region to consider
Return Value
sequence of Key instances that are in the given region
-
Obtain the index of the key in the collection that corresponds to the given position. Performs a binary search to locate the right key.
Declaration
Swift
func orderedInsertionIndex(for point: CGPoint) -> IndexParameters
pointthe location to consider
Return Value
index where to insert
View on GitHub
RandomAccessCollection Extension Reference