代码拉取完成,页面将自动刷新
invperm for immutable arrays (#52546)
# This file is a part of Julia. License is MIT: https://julialang.org/license
# ImmutableArrays (arrays that implement getindex but not setindex!)
# This test file defines an array wrapper that is immutable. It can be used to
# test the action of methods on immutable arrays.
module ImmutableArrays
export ImmutableArray
"An immutable wrapper type for arrays."
struct ImmutableArray{T,N,A<:AbstractArray} <: AbstractArray{T,N}
data::A
end
ImmutableArray(data::AbstractArray{T,N}) where {T,N} = ImmutableArray{T,N,typeof(data)}(data)
# Minimal AbstractArray interface
Base.size(A::ImmutableArray) = size(A.data)
Base.size(A::ImmutableArray, d) = size(A.data, d)
Base.getindex(A::ImmutableArray, i...) = getindex(A.data, i...)
# The immutable array remains immutable after conversion to AbstractArray
AbstractArray{T}(A::ImmutableArray) where {T} = ImmutableArray(AbstractArray{T}(A.data))
AbstractArray{T,N}(A::ImmutableArray{S,N}) where {S,T,N} = ImmutableArray(AbstractArray{T,N}(A.data))
Base.copy(A::ImmutableArray) = ImmutableArray(copy(A.data))
Base.zero(A::ImmutableArray) = ImmutableArray(zero(A.data))
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。