Skip to content

Commit

Permalink
Merge branch 'master' into mr/batch_channel_ops
Browse files Browse the repository at this point in the history
  • Loading branch information
mrufsvold authored Nov 6, 2024
2 parents 69f2d7a + 37f0220 commit 487491e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function searchsortedlast(v::AbstractVector, x, lo::T, hi::T, o::Ordering)::keyt
u = T(1)
lo = lo - u
hi = hi + u
@inbounds while lo < hi - u
@inbounds while lo != hi - u
m = midpoint(lo, hi)
if lt(o, x, v[m])
hi = m
Expand All @@ -224,7 +224,7 @@ function searchsorted(v::AbstractVector, x, ilo::T, ihi::T, o::Ordering)::UnitRa
u = T(1)
lo = ilo - u
hi = ihi + u
@inbounds while lo < hi - u
@inbounds while lo != hi - u
m = midpoint(lo, hi)
if lt(o, v[m], x)
lo = m
Expand Down
16 changes: 16 additions & 0 deletions test/sorting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,22 @@ end
# Issue #56457
o2 = OffsetArray([2,2,3], typemax(Int)-3);
@test searchsorted(o2, 2) == firstindex(o2):firstindex(o2)+1

struct IdentityVector <: AbstractVector{Int}
lo::Int
hi::Int
end
function Base.getindex(s::IdentityVector, i::Int)
s.lo <= i <= s.hi || throw(BoundsError(s, i))
i
end
Base.axes(s::IdentityVector) = (s.lo:s.hi,)
Base.size(s::IdentityVector) = length.(axes(s))

o3 = IdentityVector(typemin(Int), typemin(Int)+5)
@test searchsortedfirst(o3, typemin(Int)+2) === typemin(Int)+2
@test searchsortedlast(o3, typemin(Int)+2) === typemin(Int)+2
@test searchsorted(o3, typemin(Int)+2) === typemin(Int)+2:typemin(Int)+2
end

function adaptive_sort_test(v; trusted=InsertionSort, kw...)
Expand Down

0 comments on commit 487491e

Please sign in to comment.