title: How would you obtain the first and last items in a Queue?
body: <p>Say I have a rolling collection of values where I specify the size of the collection and any time a new value is added, any old values beyond this specified size are dropped off. Obviously (and I've tested this) the best type of collection to use for this behavior is a Queue:</p>
  
  <pre><code>myQueue.Enqueue(newValue)
  If myQueue.Count &gt; specifiedSize Then myQueue.Dequeue()
  </code></pre>
  
  <p>However, what if I want to calculate the difference between the first and last items in the Queue? Obviously I can't access the items by index. But to switch from a Queue to something implementing IList seems like overkill, as does writing a new Queue-like class. Right now I've got:</p>
  
  <pre><code>Dim firstValue As Integer = myQueue.Peek()
  Dim lastValue As Integer = myQueue.ToArray()(myQueue.Count - 1)
  Dim diff As Integer = lastValue - firstValue
  </code></pre>
  
  <p>That call to <code>ToArray()</code> bothers me, but a superior alternative isn't coming to me. Any suggestions?</p>