|
21 | 21 |
|
22 | 22 | size{T,n}(t::AbstractArray{T,n}, d) = d <= n ? size(t)[d] : 1 |
23 | 23 | size(x, d1::Integer, d2::Integer, dx::Integer...) = tuple(size(x, d1), size(x, d2, dx...)...) |
24 | | -inds(A::AbstractArray, d) = 1:size(A,d) |
25 | | -inds{T,N}(A::AbstractArray{T,N}) = ntuple(d->inds(A, d), Val{N}) |
| 24 | +indices(A::AbstractArray, d) = 1:size(A,d) |
| 25 | +indices{T,N}(A::AbstractArray{T,N}) = ntuple(d->indices(A, d), Val{N}) |
26 | 26 | eltype{T}(::Type{AbstractArray{T}}) = T |
27 | 27 | eltype{T,n}(::Type{AbstractArray{T,n}}) = T |
28 | 28 | elsize{T}(::AbstractArray{T}) = sizeof(T) |
@@ -106,7 +106,7 @@ function checkbounds(::Type{Bool}, inds::UnitRange, r::Range) |
106 | 106 | @_propagate_inbounds_meta |
107 | 107 | isempty(r) | (checkbounds(Bool, inds, first(r)) & checkbounds(Bool, inds, last(r))) |
108 | 108 | end |
109 | | -checkbounds{N}(::Type{Bool}, indx::UnitRange, I::AbstractArray{Bool,N}) = N == 1 && indx == inds(I,1) |
| 109 | +checkbounds{N}(::Type{Bool}, indx::UnitRange, I::AbstractArray{Bool,N}) = N == 1 && indx == indices(I,1) |
110 | 110 | function checkbounds(::Type{Bool}, inds::UnitRange, I::AbstractArray) |
111 | 111 | @_inline_meta |
112 | 112 | b = true |
@@ -138,13 +138,13 @@ checkbounds(A::AbstractArray, I...) = (@_inline_meta; _internal_checkbounds(A, I |
138 | 138 | # The internal function is named _internal_checkbounds since there had been a |
139 | 139 | # _checkbounds previously that meant something different. |
140 | 140 | _internal_checkbounds(A::AbstractArray) = true |
141 | | -_internal_checkbounds(A::AbstractArray, I::AbstractArray{Bool}) = inds(A) == inds(I) || throw_boundserror(A, I) |
142 | | -_internal_checkbounds(A::AbstractVector, I::AbstractVector{Bool}) = inds(A) == inds(I) || throw_boundserror(A, I) |
| 141 | +_internal_checkbounds(A::AbstractArray, I::AbstractArray{Bool}) = indices(A) == indices(I) || throw_boundserror(A, I) |
| 142 | +_internal_checkbounds(A::AbstractVector, I::AbstractVector{Bool}) = indices(A) == indices(I) || throw_boundserror(A, I) |
143 | 143 | _internal_checkbounds(A::AbstractArray, I::AbstractVector{Bool}) = length(A) == length(I) || throw_boundserror(A, I) |
144 | 144 | function _internal_checkbounds(A::AbstractArray, I1, I...) |
145 | 145 | # having I1 seems important for good codegen |
146 | 146 | @_inline_meta |
147 | | - checkbounds(Bool, inds(A), I1, I...) || throw_boundserror(A, (I1, I...)) |
| 147 | + checkbounds(Bool, indices(A), I1, I...) || throw_boundserror(A, (I1, I...)) |
148 | 148 | end |
149 | 149 |
|
150 | 150 | # See also specializations in multidimensional |
|
568 | 568 |
|
569 | 569 | typealias RangeVecIntList{A<:AbstractVector{Int}} Union{Tuple{Vararg{Union{Range, AbstractVector{Int}}}}, AbstractVector{UnitRange{Int}}, AbstractVector{Range{Int}}, AbstractVector{A}} |
570 | 570 |
|
571 | | -get(A::AbstractArray, i::Integer, default) = checkbounds(Bool, inds(A), i) ? A[i] : default |
| 571 | +get(A::AbstractArray, i::Integer, default) = checkbounds(Bool, indices(A), i) ? A[i] : default |
572 | 572 | get(A::AbstractArray, I::Tuple{}, default) = similar(A, typeof(default), 0) |
573 | | -get(A::AbstractArray, I::Dims, default) = checkbounds(Bool, inds(A), I...) ? A[I...] : default |
| 573 | +get(A::AbstractArray, I::Dims, default) = checkbounds(Bool, indices(A), I...) ? A[I...] : default |
574 | 574 |
|
575 | 575 | function get!{T}(X::AbstractArray{T}, A::AbstractArray, I::Union{Range, AbstractVector{Int}}, default::T) |
576 | 576 | ind = findin(I, 1:length(A)) |
|
0 commit comments