Skip to content

Commit d3a1c53

Browse files
committed
rename AbstractChunksIterator -> AbstractChunks
1 parent 960e2c1 commit d3a1c53

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

Diff for: src/internals.jl

+22-22
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ abstract type Constraint end
77
struct FixedCount <: Constraint end
88
struct FixedSize <: Constraint end
99

10-
abstract type AbstractChunksIterator{T,C<:Constraint,S<:Split} end
10+
abstract type AbstractChunks{T,C<:Constraint,S<:Split} end
1111

12-
struct ViewChunks{T,C<:Constraint,S<:Split} <: AbstractChunksIterator{T,C,S}
12+
struct ViewChunks{T,C<:Constraint,S<:Split} <: AbstractChunks{T,C,S}
1313
collection::T
1414
n::Int
1515
size::Int
1616
end
1717

18-
struct IndexChunks{T,C<:Constraint,S<:Split} <: AbstractChunksIterator{T,C,S}
18+
struct IndexChunks{T,C<:Constraint,S<:Split} <: AbstractChunks{T,C,S}
1919
collection::T
2020
n::Int
2121
size::Int
@@ -61,7 +61,7 @@ end
6161
is_chunkable(::Any) = false
6262
is_chunkable(::AbstractArray) = true
6363
is_chunkable(::Tuple) = true
64-
is_chunkable(::AbstractChunksIterator) = true
64+
is_chunkable(::AbstractChunks) = true
6565

6666
_set_minsize(minsize::Nothing) = 1
6767
function _set_minsize(minsize::Integer)
@@ -90,12 +90,12 @@ function err_not_chunkable(::T) where {T}
9090
throw(ArgumentError("Arguments of type $T are not compatible with chunks, either implement a custom chunks method for your type, or implement the custom type interface (see https://juliafolds2.github.io/ChunkSplitters.jl/dev/)"))
9191
end
9292

93-
Base.firstindex(::AbstractChunksIterator) = 1
93+
Base.firstindex(::AbstractChunks) = 1
9494

95-
Base.lastindex(c::AbstractChunksIterator) = length(c)
95+
Base.lastindex(c::AbstractChunks) = length(c)
9696

97-
Base.length(c::AbstractChunksIterator{T,FixedCount,S}) where {T,S} = c.n
98-
Base.length(c::AbstractChunksIterator{T,FixedSize,S}) where {T,S} = cld(length(c.collection), max(1, c.size))
97+
Base.length(c::AbstractChunks{T,FixedCount,S}) where {T,S} = c.n
98+
Base.length(c::AbstractChunks{T,FixedSize,S}) where {T,S} = cld(length(c.collection), max(1, c.size))
9999

100100
Base.getindex(c::IndexChunks{T,C,S}, i::Int) where {T,C,S} = getchunkindices(c, i)
101101
Base.getindex(c::ViewChunks{T,C,S}, i::Int) where {T,C,S} = @view(c.collection[getchunkindices(c, i)])
@@ -105,7 +105,7 @@ Base.eltype(::IndexChunks{T,C,RoundRobin}) where {T,C} = StepRange{Int,Int}
105105
Base.eltype(c::ViewChunks{T,C,Consecutive}) where {T,C} = typeof(c[firstindex(c)])
106106
Base.eltype(c::ViewChunks{T,C,RoundRobin}) where {T,C} = typeof(c[firstindex(c)])
107107

108-
function Base.iterate(c::AbstractChunksIterator, state=firstindex(c))
108+
function Base.iterate(c::AbstractChunks, state=firstindex(c))
109109
if state > lastindex(c)
110110
return nothing
111111
else
@@ -117,42 +117,42 @@ end
117117
# with `@threads` and co, because of the lack of the general definition of
118118
# `firstindex`, `lastindex`, and `getindex` for `Base.Iterators.Enumerate{<:Any}`. Thus,
119119
# to avoid using the internal `.itr` property of `Enumerate`, we redefine
120-
# the `iterate` method for `ChunkSplitters.Enumerate{<:AbstractChunksIterator}`.
121-
struct Enumerate{I<:AbstractChunksIterator}
120+
# the `iterate` method for `ChunkSplitters.Enumerate{<:AbstractChunks}`.
121+
struct Enumerate{I<:AbstractChunks}
122122
itr::I
123123
end
124-
Base.enumerate(c::AbstractChunksIterator) = Enumerate(c)
124+
Base.enumerate(c::AbstractChunks) = Enumerate(c)
125125

126-
function Base.iterate(ec::Enumerate{<:AbstractChunksIterator}, state=firstindex(ec.itr))
126+
function Base.iterate(ec::Enumerate{<:AbstractChunks}, state=firstindex(ec.itr))
127127
if state > lastindex(ec.itr)
128128
return nothing
129129
else
130130
return ((state, @inbounds(ec.itr[state])), state + 1)
131131
end
132132
end
133133

134-
Base.eltype(ec::Enumerate{<:AbstractChunksIterator{T,C,Consecutive}}) where {T,C} = Tuple{Int,eltype(ec.itr)}
135-
Base.eltype(ec::Enumerate{<:AbstractChunksIterator{T,C,RoundRobin}}) where {T,C} = Tuple{Int,eltype(ec.itr)}
134+
Base.eltype(ec::Enumerate{<:AbstractChunks{T,C,Consecutive}}) where {T,C} = Tuple{Int,eltype(ec.itr)}
135+
Base.eltype(ec::Enumerate{<:AbstractChunks{T,C,RoundRobin}}) where {T,C} = Tuple{Int,eltype(ec.itr)}
136136

137-
Base.firstindex(::Enumerate{<:AbstractChunksIterator}) = 1
137+
Base.firstindex(::Enumerate{<:AbstractChunks}) = 1
138138

139-
Base.lastindex(ec::Enumerate{<:AbstractChunksIterator}) = lastindex(ec.itr)
139+
Base.lastindex(ec::Enumerate{<:AbstractChunks}) = lastindex(ec.itr)
140140

141-
Base.getindex(ec::Enumerate{<:AbstractChunksIterator}, i::Int) = (i, ec.itr[i])
141+
Base.getindex(ec::Enumerate{<:AbstractChunks}, i::Int) = (i, ec.itr[i])
142142

143-
Base.length(ec::Enumerate{<:AbstractChunksIterator}) = length(ec.itr)
143+
Base.length(ec::Enumerate{<:AbstractChunks}) = length(ec.itr)
144144

145-
Base.eachindex(ec::Enumerate{<:AbstractChunksIterator}) = Base.OneTo(length(ec.itr))
145+
Base.eachindex(ec::Enumerate{<:AbstractChunks}) = Base.OneTo(length(ec.itr))
146146

147147
_empty_itr(::Type{Consecutive}) = 0:-1
148148
_empty_itr(::Type{RoundRobin}) = 0:1:-1
149149

150150
"""
151-
getchunkindices(c::AbstractChunksIterator, i::Integer)
151+
getchunkindices(c::AbstractChunks, i::Integer)
152152
153153
Returns the range of indices of `collection` that corresponds to the `i`-th chunk.
154154
"""
155-
function getchunkindices(c::AbstractChunksIterator{T,C,S}, ichunk::Integer) where {T,C,S}
155+
function getchunkindices(c::AbstractChunks{T,C,S}, ichunk::Integer) where {T,C,S}
156156
length(c) == 0 && return _empty_itr(S)
157157
ichunk <= length(c.collection) || throw(ArgumentError("ichunk must be less or equal to the length of the ChunksIterator"))
158158
if C == FixedCount

0 commit comments

Comments
 (0)