Skip to content

Commit

Permalink
Merge pull request #7 from JuliaArrays/teh/IndexStyle
Browse files Browse the repository at this point in the history
Fix IndexStyle depwarn on 0.6
  • Loading branch information
timholy authored Feb 18, 2017
2 parents 02feb5b + 9567565 commit 7e709ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
julia 0.5-
julia 0.5
Compat 0.19
8 changes: 5 additions & 3 deletions src/IndirectArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ __precompile__(true)

module IndirectArrays

using Compat

export IndirectArray

"""
Expand All @@ -15,18 +17,18 @@ immutable IndirectArray{T,N,I<:Integer} <: AbstractArray{T,N}
index::Array{I,N}
values::Vector{T}

@inline function IndirectArray(index, values)
@inline function (::Type{IndirectArray{T,N,I}}){T,N,I}(index, values)
# The typical logic for testing bounds and then using
# @inbounds will not check whether index is inbounds for
# values. So we had better check this on construction.
@boundscheck checkbounds(values, index)
new(index, values)
new{T,N,I}(index, values)
end
end
Base.@propagate_inbounds IndirectArray{T,N,I<:Integer}(index::Array{I,N},values::Vector{T}) = IndirectArray{T,N,I}(index,values)

Base.size(A::IndirectArray) = size(A.index)
Base.linearindexing(A::IndirectArray) = Base.LinearFast()
@compat Base.IndexStyle(::Type{<:IndirectArray}) = IndexLinear()

@inline function Base.getindex(A::IndirectArray, i::Int)
@boundscheck checkbounds(A.index, i)
Expand Down

0 comments on commit 7e709ac

Please sign in to comment.