@@ -397,6 +397,12 @@ module IteratorsMD
397
397
getindex (iter, C. indices... )
398
398
end
399
399
@inline Base. getindex (iter:: CartesianIndices{0} , :: CartesianIndices{0} ) = iter
400
+ @inline function Base. getindex (iter:: CartesianIndices{N} , r:: StepRangeLen{CartesianIndex{N},CartesianIndex{N},CartesianIndex{N},<:Integer} ) where {N}
401
+ @boundscheck checkbounds (iter, r)
402
+ start = first (iter) + first (r) - CartesianIndex (first .(axes (iter)))
403
+ stepsz = CartesianIndex (Tuple (step (iter)) .* Tuple (step (r)))
404
+ StepRangeLen (start, stepsz, length (r))
405
+ end
400
406
401
407
# If dimensions permit, we may index into a CartesianIndices directly instead of constructing a SubArray wrapper
402
408
@propagate_inbounds function Base. view (c:: CartesianIndices{N} , r:: Vararg{Union{OrdinalRange{<:Integer, <:Integer}, Colon},N} ) where {N}
735
741
@inline checkindex (:: Type{Bool} , inds:: Tuple , I:: CartesianIndex ) =
736
742
checkbounds_indices (Bool, inds, I. I)
737
743
@inline checkindex (:: Type{Bool} , inds:: Tuple , i:: AbstractRange{<:CartesianIndex} ) =
738
- isempty (i) | (checkindex (Bool, inds, first (i)) & checkindex (Bool, inds, last (i)))
744
+ isempty (i) || (checkindex (Bool, inds, first (i)) & checkindex (Bool, inds, last (i)))
739
745
740
746
# Indexing into Array with mixtures of Integers and CartesianIndices is
741
747
# extremely performance-sensitive. While the abstract fallbacks support this,
0 commit comments