From 758129dfd22258c0433b801b99df627f00ff8246 Mon Sep 17 00:00:00 2001 From: KronosTheLate Date: Thu, 25 Jan 2024 15:11:10 +0100 Subject: [PATCH 1/4] gitignore .vscode, fix Deque --- .gitignore | 1 + src/deque.jl | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fb1a162b6..156c9d084 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ docs/site/ docs/Manifest.toml Manifest.toml benchmark/*.json +.vscode diff --git a/src/deque.jl b/src/deque.jl index ce4544b10..01421711d 100644 --- a/src/deque.jl +++ b/src/deque.jl @@ -20,13 +20,16 @@ mutable struct DequeBlock{T} blk.next = blk return blk end + + # Convert any `Integer` to whatever `Int` is on the relevant machine + DequeBlock{T}(capa::Integer, front::Integer) where T = DequeBlock{T}(Int(capa), Int(front)) end # block at the rear of the chain, elements towards the front -rear_deque_block(ty::Type{T}, n::Int) where {T} = DequeBlock{T}(n, 1) +rear_deque_block(ty::Type{T}, n::Integer) where {T} = DequeBlock{T}(n, 1) # block at the head of the train, elements towards the back -head_deque_block(ty::Type{T}, n::Int) where {T} = DequeBlock{T}(n, n+1) +head_deque_block(ty::Type{T}, n::Integer) where {T} = DequeBlock{T}(n, n+1) capacity(blk::DequeBlock) = blk.capa Base.length(blk::DequeBlock) = blk.back - blk.front + 1 @@ -80,7 +83,7 @@ mutable struct Deque{T} head::DequeBlock{T} rear::DequeBlock{T} - function Deque{T}(blksize::Int) where T + function Deque{T}(blksize::Integer) where T head = rear = rear_deque_block(T, blksize) new{T}(1, blksize, 0, head, rear) end From 2262f63698d19eb9de6c43bdc9833d0ec7abddcb Mon Sep 17 00:00:00 2001 From: KronosTheLate Date: Thu, 25 Jan 2024 15:16:51 +0100 Subject: [PATCH 2/4] Int -> Integer in `reset!`. Not tested --- src/deque.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deque.jl b/src/deque.jl index 01421711d..1ba54c131 100644 --- a/src/deque.jl +++ b/src/deque.jl @@ -40,7 +40,7 @@ isrear(blk::DequeBlock) = blk.next === blk # reset the block to empty, and position -function reset!(blk::DequeBlock{T}, front::Int) where T +function reset!(blk::DequeBlock{T}, front::Integer) where T empty!(blk.data) resize!(blk.data, blk.capa) blk.front = front From d119d1efc491b3fca96b396b359cb752a332d8a4 Mon Sep 17 00:00:00 2001 From: KronosTheLate Date: Thu, 25 Jan 2024 15:21:38 +0100 Subject: [PATCH 3/4] fix CircularBuffer --- src/circular_buffer.jl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/circular_buffer.jl b/src/circular_buffer.jl index e1a6a88d7..88459d8fa 100644 --- a/src/circular_buffer.jl +++ b/src/circular_buffer.jl @@ -19,18 +19,21 @@ mutable struct CircularBuffer{T} <: AbstractVector{T} len <= length(buf) || throw(ArgumentError("Value of 'length' must be <= length of buffer")) return new{T}(length(buf), f, len, buf) end + + # Convert any `Integer` to whatever `Int` is on the relevant machine + CircularBuffer{T}(f::Integer, len::Integer, buf::Integer) where {T} = CircularBuffer{T}(Int(f), Int(len), Int(buf)) end -function CircularBuffer{T}(iter, capacity::Int) where {T} +function CircularBuffer{T}(iter, capacity::Integer) where {T} vec = copyto!(Vector{T}(undef,capacity), iter) CircularBuffer{T}(1, length(iter),vec) end -CircularBuffer(capacity::Int) = CircularBuffer{Any}(capacity) +CircularBuffer(capacity::Integer) = CircularBuffer{Any}(capacity) -CircularBuffer{T}(capacity::Int) where {T} = CircularBuffer{T}(T[],capacity) +CircularBuffer{T}(capacity::Integer) where {T} = CircularBuffer{T}(T[],capacity) -CircularBuffer(iter,capacity::Int) = CircularBuffer{eltype(iter)}(iter,capacity) +CircularBuffer(iter,capacity::Integer) = CircularBuffer{eltype(iter)}(iter,capacity) function CircularBuffer{T}(iter) where {T} vec = reshape(collect(T,iter),:) From e4d7d54e352f2cfd33c73c13c85daa9348768576 Mon Sep 17 00:00:00 2001 From: KronosTheLate Date: Thu, 25 Jan 2024 15:24:17 +0100 Subject: [PATCH 4/4] fix CircularDeque --- src/circ_deque.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/circ_deque.jl b/src/circ_deque.jl index 3159d7d6a..a6520e5fa 100644 --- a/src/circ_deque.jl +++ b/src/circ_deque.jl @@ -12,6 +12,7 @@ end Create a double-ended queue of maximum capacity `n`, implemented as a circular buffer. The element type is `T`. """ CircularDeque{T}(n::Int) where {T} = CircularDeque(Vector{T}(undef, n), n, 0, 1, n) +CircularDeque{T}(n::Integer) where {T} = CircularDeque(Vector{T}(undef, Int(n)), Int(n), 0, 1, Int(n)) Base.length(D::CircularDeque) = D.n Base.eltype(::Type{CircularDeque{T}}) where {T} = T