Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/FSharpx.Collections/CircularBuffer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ type CircularBuffer<'T>(bufferSize: int) =

let mutable offset = offset

head <- (head + 1) % bufferSize
let startPos = (head + 1) % bufferSize

for x, y in nextBuffer head count do
for x, y in nextBuffer startPos count do
Array.blit value offset buffer x y
offset <- offset + y

head <- (head + count) % bufferSize

if length = bufferSize then
tail <- (tail + count) % bufferSize
else
Expand Down
6 changes: 3 additions & 3 deletions tests/FSharpx.Collections.Tests/CircularBufferTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module CircularBufferTests =
Expect.throwsT<System.InvalidOperationException> "" f
}

ptest "Printing after multiple enqueue circles" {
test "Printing after multiple enqueue circles" {
let circularBuffer = CircularBuffer<int> 5

circularBuffer.Enqueue [| 1; 2; 3; 4; 5 |]
Expand All @@ -96,7 +96,7 @@ module CircularBufferTests =



ptest "Printing from a queue 1..8 and dequeue 5, then enqueue 1..3 and dequeue 3, from array" {
test "Printing from a queue 1..8 and dequeue 5, then enqueue 1..3 and dequeue 3, from array" {
let circularBuffer = CircularBuffer<int> 5

circularBuffer.Enqueue([| 1; 2; 3; 4; 5 |])
Expand All @@ -106,7 +106,7 @@ module CircularBufferTests =
Expect.equal "buffer" [| 1; 2; 3 |] <| circularBuffer.Dequeue 3
}

ptest "Consider a large array with various, incoming array segments" {
test "Consider a large array with various, incoming array segments" {
let circularBuffer = CircularBuffer<int> 5

let source =
Expand Down
Loading