Skip to content

Commit 0b9fcb5

Browse files
xili-hxili
andauthored
Implement faster issubset for CartesianIndices{N} (#56282)
Co-authored-by: xili <[email protected]>
1 parent 133051f commit 0b9fcb5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

base/multidimensional.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,8 @@ module IteratorsMD
615615
# array operations
616616
Base.intersect(a::CartesianIndices{N}, b::CartesianIndices{N}) where N =
617617
CartesianIndices(intersect.(a.indices, b.indices))
618+
Base.issubset(a::CartesianIndices{N}, b::CartesianIndices{N}) where N =
619+
isempty(a) || all(map(issubset, a.indices, b.indices))
618620

619621
# Views of reshaped CartesianIndices are used for partitions — ensure these are fast
620622
const CartesianPartition{T<:CartesianIndex, P<:CartesianIndices, R<:ReshapedArray{T,1,P}} = SubArray{T,1,R,<:Tuple{AbstractUnitRange{Int}},false}

0 commit comments

Comments
 (0)