[swift-users] Collection underestimatedCount() does _?

Dmitri Gribenko gribozavr at gmail.com
Sat Mar 19 01:08:23 CDT 2016


On Fri, Mar 18, 2016 at 10:53 PM, Will Stanton via swift-users
<swift-users at swift.org> wrote:
> 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?

Hi Will,

This API comes from Sequence, which does not have a count that you can
inspect without possibly consuming the sequence.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-users mailing list