anchor.diff:  Debug.Assert([|1;2;3|] = queue.Dequeue(3))
   
   printfn "Enqueue(array) tests passed in %d ms" stopwatch.ElapsedMilliseconds
  +
  +stopwatch.Reset()
  +stopwatch.Start()
  +
  +// Consider a large array with various, incoming array segments.
  +let source =
  +    [| 1;2;3;4;5
  +       1;2;3;4;5;6;7;8;1;2;3;4;5;6;7;8
  +       1;2;3;4;5
  +       1;2;3
  +       1;2;3;4;5;6;7;8
  +       1;2;3 |]
  +
  +let incoming =
  +    let generator =
  +        seq { yield ArraySegment<_>(source,0,5)
  +//              Threading.Thread.Sleep(1)
  +              yield ArraySegment<_>(source,5,16)
  +//              Threading.Thread.Sleep(2)
  +              yield ArraySegment<_>(source,21,5)
  +//              Threading.Thread.Sleep(1)
  +              yield ArraySegment<_>(source,26,3)
  +//              Threading.Thread.Sleep(1)
  +              yield ArraySegment<_>(source,29,8)
  +//              Threading.Thread.Sleep(1)
  +              yield ArraySegment<_>(source,37,3) } 
  +    in generator.GetEnumerator()
  +
  +let enqueueNext() =
  +    incoming.MoveNext() |> ignore
  +    queue.Enqueue(incoming.Current)
  +
  +// Printing from a queue 1..5
  +enqueueNext()
  +Debug.Assert([|1;2;3;4;5|] = queue.Dequeue(5))
  +
  +// Printing from a queue 1..8, twice
  +enqueueNext()
  +Debug.Assert([|4;5;6;7;8|] = queue.Dequeue(5))
  +
  +// Printing from a queue 1..5
  +enqueueNext()
  +Debug.Assert([|1;2;3|] = queue.Dequeue(3))
  +
  +// Clear out the rest
  +queue.Dequeue(2)
  +
  +// Printing from a queue 1..3
  +enqueueNext()
  +Debug.Assert([|1;2;3|] = queue.Dequeue(3))
  +
  +// Printing from a queue 1..8 and dequeue 5, then enqueue 1..3 and dequeue 3
  +enqueueNext()
  +Debug.Assert([|4;5;6;7;8|] = queue.Dequeue(5))
  +enqueueNext()
  +Debug.Assert([|1;2;3|] = queue.Dequeue(3))
  +
  +printfn "Enqueue(array) tests passed in %d ms" stopwatch.ElapsedMilliseconds
  +// [/snippet]
  
positive.code:                 yield (offset, count)
          }
  
      member this.Dequeue(count) =
          if length = 0 then invalidOp "Queue exhausted."
          if count > length then invalidOp "Requested count is too large."
  
  
negative.code:         length <- length - count
          dequeued
  
      member __.Enqueue(value: _[], offset, count) =
          let mutable offset = offset
  
          // NOTE: We could save a lot by just pulling the last
          // bufferSize elements, but we'll be converting to a
          // blocking agent eventually.
          head <- (head + 1) % bufferSize
          for x, y in nextBuffer head count do
              Array.blit value offset buffer x y
              offset <- offset + y
  
          if length = bufferSize then
              tail <- (tail + count) % bufferSize
          else
              let overflow = length + count - bufferSize
              if overflow > 0 then
                  tail <- (tail + overflow) % bufferSize
              length <- min (length + count) bufferSize
  
      member __.Enqueue(value: _[]) =
          __.Enqueue(value, 0, value.Length)
  
      member __.Enqueue(value: _[], offset) =
          __.Enqueue(value, offset, value.Length - offset)
  
      member __.Enqueue(value: ArraySegment<_>) =
          __.Enqueue(value.Array, value.Offset, value.Count)
  
      member __.Enqueue(value) =
          __.Enqueue([|value|], 0, 1)
  // [/snippet]
  
  // [snippet: Usage]
  let queue = CircularBuffer(5)
  
  let stopwatch = Stopwatch.StartNew()
  