diff --git a/j/abstractarray.j b/j/abstractarray.j index 2ce5cc3435f40..54cbe92434425 100644 --- a/j/abstractarray.j +++ b/j/abstractarray.j @@ -15,8 +15,7 @@ typealias RangeIndex Union(Int, Range{Int}, Range1{Int}) size{T,n}(t::AbstractArray{T,n}, d) = (d>n ? 1 : size(t)[d]) eltype{T,n}(::AbstractArray{T,n}) = T ndims{T,n}(::AbstractArray{T,n}) = n -numel(t::AbstractArray) = prod(size(t)) -length(a::AbstractArray) = numel(a) +length(t::AbstractArray) = prod(size(t)) first(a::AbstractArray) = a[1] last(a::AbstractArray) = a[end] diff --git a/j/array.j b/j/array.j index db1b72604b7f9..6f89df5fed033 100644 --- a/j/array.j +++ b/j/array.j @@ -14,7 +14,7 @@ typealias StridedVecOrMat{T} Union(StridedVector{T}, StridedMatrix{T}) size(a::Array) = arraysize(a) size(a::Array, d) = arraysize(a, d) size(a::Matrix) = (arraysize(a,1), arraysize(a,2)) -numel(a::Array) = arraylen(a) +length(a::Array) = arraylen(a) ## copy ## diff --git a/j/base.j b/j/base.j index 40880388882fb..816fc3f3a75ee 100644 --- a/j/base.j +++ b/j/base.j @@ -105,7 +105,7 @@ function append_any(xs...) # exact function. n = 0 for x = xs - n += numel(x) + n += length(x) end out = Array(Any, n) i = 1 diff --git a/j/intset.j b/j/intset.j index 4b2c6b70e95b6..a4f66e62ad75c 100644 --- a/j/intset.j +++ b/j/intset.j @@ -121,7 +121,7 @@ function pop(s::IntSet) n end -numel(s::IntSet) = +length(s::IntSet) = int(ccall(:bitvector_count, Uint64, (Ptr{Uint32}, Uint64, Uint64), s.bits, uint64(0), uint64(s.limit))) diff --git a/j/number.j b/j/number.j index 226f33ef08374..ec75a250d56ad 100644 --- a/j/number.j +++ b/j/number.j @@ -15,7 +15,6 @@ const islogical = isbool size(x::Number) = () ndims(x::Number) = 0 -numel(x::Number) = 1 length(x::Number) = 1 ref(x::Number) = x diff --git a/j/range.j b/j/range.j index 21245b42f8c73..dcc9187847e03 100644 --- a/j/range.j +++ b/j/range.j @@ -57,8 +57,8 @@ colon(start::Real, stop::Real) = colon(promote(start, stop)...) similar(r::Ranges, T::Type, dims::Dims) = Array(T, dims) length(r::Ranges) = r.len +const numel = length size(r::Ranges) = (r.len,) -numel(r::Ranges) = r.len isempty(r::Ranges) = r.len==0 first(r::Ranges) = r.start last{T}(r::Range{T}) = r.start + oftype(T,r.len-1)*step(r) diff --git a/j/set.j b/j/set.j index e5c4a55bc3529..324e5141974b6 100644 --- a/j/set.j +++ b/j/set.j @@ -11,7 +11,7 @@ Set{T}(x::T...) = Set{T}(x...) show(s::Set) = (show(typeof(s)); show_comma_array(s,'(',')')) isempty(s::Set) = isempty(s.hash) -numel(s::Set) = numel(s.hash) +length(s::Set) = length(s.hash) eltype{T}(s::Set{T}) = T has(s::Set, x) = has(s.hash, x) diff --git a/j/sparse.j b/j/sparse.j index 9740564cf7a99..32a5831e7a404 100644 --- a/j/sparse.j +++ b/j/sparse.j @@ -746,7 +746,6 @@ end SparseAccumulator(s::Integer) = SparseAccumulator(Float64, Int32, s) length(S::SparseAccumulator) = length(S.vals) -numel(S::SparseAccumulator) = S.nvals # store spa and reset function _jl_spa_store_reset{T}(S::SparseAccumulator{T}, col, colptr, rowval, nzval) diff --git a/j/string.j b/j/string.j index 38fd08d9b0966..561e01dfea8ea 100644 --- a/j/string.j +++ b/j/string.j @@ -9,7 +9,6 @@ next(s::String, i::Integer) = next(s,int(i)) start(s::String) = 1 done(s::String,i) = (i > length(s)) -numel(s::String) = length(s) isempty(s::String) = done(s,start(s)) ref(s::String, i::Int) = next(s,i)[1] ref(s::String, i::Integer) = s[int(i)] diff --git a/j/table.j b/j/table.j index a05f75b074854..523a659f14000 100644 --- a/j/table.j +++ b/j/table.j @@ -201,7 +201,7 @@ function assign{K,V}(h::HashTable{K,V}, v, key) sz = length(h.keys) - if numel(h.deleted) >= ((3*sz)>>2) + if length(h.deleted) >= ((3*sz)>>2) rehash(h, sz) end @@ -305,7 +305,7 @@ next(t::HashTable, i) = ((n, nxt) = next(t.used, i); skip_deleted(t.used,t.deleted,nxt))) isempty(t::HashTable) = done(t, start(t)) -numel(t::HashTable) = numel(t.used)-numel(t.deleted) +length(t::HashTable) = length(t.used)-length(t.deleted) function add_weak_key(t::HashTable, k, v) if is(t.deleter, identity) diff --git a/j/tuple.j b/j/tuple.j index 289112a8daaf0..773d44e566fcf 100644 --- a/j/tuple.j +++ b/j/tuple.j @@ -1,7 +1,6 @@ ## indexing ## length(t::Tuple) = tuplelen(t) -numel (t::Tuple) = tuplelen(t) size(t::Tuple, d) = d==1 ? tuplelen(t) : error("invalid tuple dimension") ref(t::Tuple, i::Int) = tupleref(t, i) ref(t::Tuple, i::Integer) = tupleref(t, int(i))