title: Simplified algorithm for calculating remaining space in a circular buffer?
body: <p>I was wonder if there is a simpler (single) way to calculate the remaining space in a circular buffer than this?</p>
  
  <pre><code>int remaining = (end &gt; start)
                  ? end-start
                  : bufferSize - start + end;
  </code></pre>