Skip to content

Commit

Permalink
Rename Iterator type.
Browse files Browse the repository at this point in the history
  • Loading branch information
weinbe58 committed Jan 2, 2024
1 parent b2d36ca commit b6e4278
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/interface.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

struct DP5Iterator{T <: Real}
struct SolverIterator{T <: Real}
solver::AbstractDPSolver
times::AbstractVector{T}
end

# gets the first (t,y), return index which is the state
# here we choose 2 because 1 is the initial state which
# is has been returned by the iterator
function Base.iterate(dp5_iterator::DP5Iterator)
function Base.iterate(dp5_iterator::SolverIterator)
length(dp5_iterator.times) == 0 && return nothing # empty iterator
# integrate to first time
integrate(dp5_iterator.solver, first(dp5_iterator.times))
Expand All @@ -16,7 +16,7 @@ function Base.iterate(dp5_iterator::DP5Iterator)
end

# gets the next (t,y), return index+! which is the updated state
function Base.iterate(dp5_iterator::DP5Iterator, index::Int)
function Base.iterate(dp5_iterator::SolverIterator, index::Int)
index > length(dp5_iterator.times) && return nothing # end of iterator
# integrate to next time
integrate(dp5_iterator.solver, dp5_iterator.times[index])
Expand All @@ -29,7 +29,7 @@ end
# 2. integrate(solver, times) -> iterator
# 3. integrate(callback, solver, times) -> vector of states with callback applied

integrate(solver::AbstractDPSolver{T}, times::AbstractVector{T}) where {T <: Real} = DP5Iterator(solver, times)
integrate(solver::AbstractDPSolver{T}, times::AbstractVector{T}) where {T <: Real} = SolverIterator(solver, times)

function integrate(callback, solver::AbstractDPSolver{T}, times::AbstractVector{T}; sort_times::Bool = true) where {T <: Real}
times = sort_times ? sort(collect(times)) : times
Expand Down

0 comments on commit b6e4278

Please sign in to comment.