Skip to content

Commit

Permalink
Revert "Make nextindex more compatible with findnext"
Browse files Browse the repository at this point in the history
This reverts commit 3da037d.
  • Loading branch information
lkdvos committed Jun 3, 2024
1 parent 4186efc commit 18b19b3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/utility/utility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,14 @@ end
end

"""
nextindex(A, idx)
nextindex(collection, idx)
Return the next index of `A`, or nothing if `idx` is the last index.
Indices are of the same type as those returned by `keys(A)` and `pairs(A)`.
Return the next index of `collection`, or nothing if `idx` is the last index, as defined by iterating over `eachindex`.
See also: [`firstindex`](@ref), [`lastindex`](@ref)
"""
nextindex(A::AbstractArray, idx) = findnext(i -> true, A, idx)
function nextindex(A::AbstractArray, idx::Int)
nextidx = Base.iterate(eachindex(A), idx)
isnothing(nextidx) && return nothing
return nextidx[1]
end

0 comments on commit 18b19b3

Please sign in to comment.