Skip to content

Commit 6accda3

Browse files
committed
Revert "More fixes for non-1 arrays"
This reverts commit 39cd805.
1 parent 3a873fe commit 6accda3

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

base/abstractarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ julia> length(A)
125125
length(t::AbstractArray) = prod(size(t))
126126
_length(A::AbstractArray) = prod(map(unsafe_length, indices(A))) # circumvent missing size
127127
_length(A) = length(A)
128-
endof(a::AbstractArray) = last(linearindices(a))
128+
endof(a::AbstractArray) = length(a)
129129
first(a::AbstractArray) = a[first(eachindex(a))]
130130

131131
function first(itr)

base/array.jl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -690,30 +690,26 @@ function lexcmp(a::Array{UInt8,1}, b::Array{UInt8,1})
690690
return c < 0 ? -1 : c > 0 ? +1 : cmp(length(a),length(b))
691691
end
692692

693-
function reverse(A::AbstractVector, s=first(linearindices(A)), n=last(linearindices(A)))
693+
function reverse(A::AbstractVector, s=1, n=length(A))
694694
B = similar(A)
695-
for i = first(linearindices(A)):s-1
695+
for i = 1:s-1
696696
B[i] = A[i]
697697
end
698698
for i = s:n
699699
B[i] = A[n+s-i]
700700
end
701-
for i = n+1:last(linearindices(A))
701+
for i = n+1:length(A)
702702
B[i] = A[i]
703703
end
704704
return B
705705
end
706-
function reverseind(a::AbstractVector, i::Integer)
707-
li = linearindices(a)
708-
first(li) + last(li) - i
709-
end
706+
reverseind(a::AbstractVector, i::Integer) = length(a) + 1 - i
710707

711-
function reverse!(v::AbstractVector, s=first(linearindices(v)), n=last(linearindices(v)))
712-
liv = linearindices(v)
708+
function reverse!(v::AbstractVector, s=1, n=length(v))
713709
if n <= s # empty case; ok
714-
elseif !(first(liv) s last(liv))
710+
elseif !(1 s endof(v))
715711
throw(BoundsError(v, s))
716-
elseif !(first(liv) n last(liv))
712+
elseif !(1 n endof(v))
717713
throw(BoundsError(v, n))
718714
end
719715
r = n

test/offsetarray.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,19 +268,9 @@ am = map(identity, a)
268268

269269
# other functions
270270
v = OffsetArray(v0, (-3,))
271-
@test endof(v) == 1
272271
@test_approx_eq v v
273272
@test parent(v') == v0'
274273
@test indices(v') === (1:1,-2:1)
275-
rv = reverse(v)
276-
@test indices(rv) == indices(v)
277-
@test rv[1] == v[-2]
278-
@test rv[0] == v[-1]
279-
@test rv[-1] == v[0]
280-
@test rv[-2] == v[1]
281-
cv = copy(v)
282-
@test reverse!(cv) == rv
283-
284274
A = OffsetArray(rand(4,4), (-3,5))
285275
@test_approx_eq A A
286276
@test maximum(A) == maximum(parent(A))

0 commit comments

Comments
 (0)