@@ -403,6 +403,12 @@ module IteratorsMD
403
403
getindex (iter, C. indices... )
404
404
end
405
405
@inline Base. getindex (iter:: CartesianIndices{0} , :: CartesianIndices{0} ) = iter
406
+ @inline function Base. getindex (iter:: CartesianIndices{N} , r:: StepRangeLen{CartesianIndex{N},CartesianIndex{N},CartesianIndex{N},<:Integer} ) where {N}
407
+ @boundscheck checkbounds (iter, r)
408
+ start = first (iter) + first (r) - CartesianIndex (first .(axes (iter)))
409
+ stepsz = CartesianIndex (Tuple (step (iter)) .* Tuple (step (r)))
410
+ StepRangeLen (start, stepsz, length (r))
411
+ end
406
412
407
413
# If dimensions permit, we may index into a CartesianIndices directly instead of constructing a SubArray wrapper
408
414
@propagate_inbounds function Base. view (c:: CartesianIndices{N} , r:: Vararg{Union{OrdinalRange{<:Integer, <:Integer}, Colon},N} ) where {N}
743
749
@inline checkindex (:: Type{Bool} , inds:: Tuple , I:: CartesianIndex ) =
744
750
checkbounds_indices (Bool, inds, I. I)
745
751
@inline checkindex (:: Type{Bool} , inds:: Tuple , i:: AbstractRange{<:CartesianIndex} ) =
746
- isempty (i) | (checkindex (Bool, inds, first (i)) & checkindex (Bool, inds, last (i)))
752
+ isempty (i) || (checkindex (Bool, inds, first (i)) & checkindex (Bool, inds, last (i)))
747
753
748
754
# Indexing into Array with mixtures of Integers and CartesianIndices is
749
755
# extremely performance-sensitive. While the abstract fallbacks support this,
0 commit comments