Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractIndicesArray Examples #6

Open
Tokazama opened this issue Feb 29, 2020 · 0 comments
Open

AbstractIndicesArray Examples #6

Tokazama opened this issue Feb 29, 2020 · 0 comments

Comments

@Tokazama
Copy link
Owner

Tokazama commented Feb 29, 2020

There need to be examples for subtyping AbstractIndicesArray. A neat example might be how to recreate the SArray using static axes instead of a statically defined size.

Here's some very brief code that would illustrate this...

"""
    AxisMArray

An array whose elements are mutable.
"""
struct AxisMArray{T,N,Axs<:Tuple} <: AbstractAxisArray{T,N,Axs}
    data::Vector{T}
    axes::LinearAxes{N,Axs}

    function AxisMArray{T,N,Axs}(data::Vector{T}, axes::Axs) where {T,N,Axs}
        return new{T,N,Axs}(data, axes)
    end
end

"""
    AxisIArray

An array elements are immutable.
"""
struct AxisIArray{T,N,Axs<:Tuple,L} <: AbstractAxisArray{T,N,Axs}
    data::SVector{L,T}
    axes::LinearAxes{N,Axs}

    function AxisIArray{T,N,Axs,L}(data::SVector{L,T}, axes::Axs) where {T,N,Axs,L}
        return new{T,N,Axs,L}(data, axes)
    end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant