<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Daryle,<div class=""><br class=""></div><div class="">Good spot! This is definitely a bug. The documentation on Sequence should read something different (though what it ought to say is somewhat debatable…).</div><div class=""><br class=""></div><div class="">Could you file a bug on <a href="http://bugs.swift.org" class="">bugs.swift.org</a>?</div><div class=""><br class=""></div><div class="">Thanks!<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 29, 2017, at 17:54, Daryle Walker via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Sequence.underestimatedCount is supposed to work at O(1) time, according to the docs on Apple’s developer website. On the other hand, Collection.count works at O(n) time, except for RandomAccessCollection where it can work at O(1) time. I’ve been playing around with creating various Collection types, and it seem that their underestimatedCount has a default implementation that just dumps to count, even when the latter is O(n)!</div><div class=""><br class=""></div><div class="">I think that underestimatedCount should call count only for RandomAccessCollection, while Collection and BidirectionalCollection call isEmpty as needed. Is this a good idea? Should I post a bug report (somewhere)?</div><br class=""><div class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">—&nbsp;</div><div class="">Daryle Walker<br class="">Mac, Internet, and Video Game Junkie<br class="">darylew AT mac DOT com&nbsp;</div></div>
</div>
<br class=""></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>