Hello,

I came across `underestimatedCount()` and wonder what it does. I’m trying to 
become more familiar with Swift collections so (perhaps) I can write 
better-performing code!


/// Returns a value less than or equal to the number of elements in
/// `self`, *nondestructively*.
///
/// - Complexity: O(N).
public func underestimateCount() -> Int
/// Returns the number of elements.
///
/// - Complexity: O(1) if `Index` conforms to `RandomAccessIndexType`;
///   O(N) otherwise.
public var count: Self.Index.Distance { get }


I might have missed something since a lot of the results are for tests 
<https://github.com/apple/swift/search?utf8=✓&q=underestimatedCount&type=Code>
But why would `underestimatedCount` ever be used instead of `count`? Don’t most 
collections have O(1) `count` anyway?

Regards,
Will Stanton

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to