<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 9, 2011, at 5:36 PM, Eli Friedman wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div><blockquote type="cite">+  /// getNumBlocks - Get the number of blocks in this loop.<br></blockquote><blockquote type="cite">+  unsigned getNumBlocks() const {<br></blockquote><blockquote type="cite">+    return std::distance(block_begin(), block_end());<br></blockquote><blockquote type="cite">+  }<br></blockquote><br>I do not think this is a good idea; any user that cares can write the<br>expression with std::distance, and having an accessor gives the<br>illusion that it's constant time.</div></span></blockquote></div><br><div>I wanted a way to stress that Loop needs to provide a constant-time accessor for number of blocks. It's an assumption made by LoopIterator and a few other places (some I have not checked in yet).</div><div><br></div><div>Using std::distance was unnecessary, I cleaned it up. I also didn't notice the getBlocks() accessor. Feel free to replace uses of getNumBlocks with it, although I was trying not to expose the Blocks type to the client code.</div><div><br></div><div>-Andy</div></body></html>