Skip to content

Commit 0b06c5a

Browse files
authored
Merge pull request #668 from invenia/npr/using-not-import
Replace `import` with `using`
2 parents 79cabfc + 8e9dd00 commit 0b06c5a

31 files changed

+512
-579
lines changed

src/DataStructures.jl

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
module DataStructures
22

3-
import Base: <, <=, ==, length, isempty, iterate,
4-
show, dump, empty!, getindex, setindex!, get, get!,
5-
in, haskey, keys, merge, copy, cat, collect,
6-
push!, pop!, pushfirst!, popfirst!, insert!, lastindex,
7-
union!, delete!, similar, sizehint!, empty, append!,
8-
isequal, hash, map, filter, reverse, peek,
9-
first, last, eltype, getkey, values, sum,
10-
merge, merge!, lt, Ordering, ForwardOrdering, Forward,
11-
ReverseOrdering, Reverse, Lt,
12-
isless, union, intersect, symdiff, setdiff, issubset,
13-
searchsortedfirst, searchsortedlast, in,
14-
eachindex, keytype, valtype, minimum, maximum, size,
15-
zero, checkbounds, filter!, isbitstype, isbitsunion,
16-
isiterable, dict_with_eltype, KeySet, Callable, _tablesz
3+
using Base: HasEltype, HasLength, IteratorEltype, IteratorSize, SizeUnknown,
4+
lt, Ordering, ForwardOrdering, Forward, ReverseOrdering, Reverse, Lt,
5+
isbitsunion, isiterable, dict_with_eltype, KeySet, Callable, _tablesz,
6+
findnextnot, unsafe_getindex, unsafe_setindex!, peek
177

188

199
using Compat # Provides Base.Order.ReverseOrdering(). May remove this line with julia 1.4
2010
using OrderedCollections
21-
import OrderedCollections: filter, filter!, isordered
11+
using OrderedCollections: isordered
2212
export OrderedDict, OrderedSet, LittleDict
2313
export DefaultDict, DefaultOrderedDict
2414

src/accumulator.jl

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,32 @@ function eltype_for_accumulator(seq::Base.Generator)
3838
end
3939

4040

41-
copy(ct::Accumulator) = Accumulator(copy(ct.map))
41+
Base.copy(ct::Accumulator) = Accumulator(copy(ct.map))
4242

43-
length(a::Accumulator) = length(a.map)
43+
Base.length(a::Accumulator) = length(a.map)
4444

4545
## retrieval
4646

47-
get(ct::Accumulator, x, default) = get(ct.map, x, default)
47+
Base.get(ct::Accumulator, x, default) = get(ct.map, x, default)
4848
# need to allow user specified default in order to
4949
# correctly implement "informal" AbstractDict interface
5050

51-
getindex(ct::Accumulator{T,V}, x) where {T,V} = get(ct.map, x, zero(V))
51+
Base.getindex(ct::Accumulator{T,V}, x) where {T,V} = get(ct.map, x, zero(V))
5252

53-
setindex!(ct::Accumulator, x, v) = setindex!(ct.map, x, v)
53+
Base.setindex!(ct::Accumulator, x, v) = setindex!(ct.map, x, v)
5454

5555

56-
haskey(ct::Accumulator, x) = haskey(ct.map, x)
56+
Base.haskey(ct::Accumulator, x) = haskey(ct.map, x)
5757

58-
keys(ct::Accumulator) = keys(ct.map)
58+
Base.keys(ct::Accumulator) = keys(ct.map)
5959

60-
values(ct::Accumulator) = values(ct.map)
60+
Base.values(ct::Accumulator) = values(ct.map)
6161

62-
sum(ct::Accumulator) = sum(values(ct.map))
62+
Base.sum(ct::Accumulator) = sum(values(ct.map))
6363

6464
## iteration
6565

66-
iterate(ct::Accumulator, s...) = iterate(ct.map, s...)
66+
Base.iterate(ct::Accumulator, s...) = iterate(ct.map, s...)
6767

6868
# manipulation
6969

@@ -77,12 +77,11 @@ inc!(ct::Accumulator{T, V}, x) where {T, V} = inc!(ct, x, one(V))
7777

7878
# inc! is preferred over push!, but we need to provide push! for the Bag interpreation
7979
# which is used by classified_collections.jl
80-
push!(ct::Accumulator, x) = inc!(ct, x)
81-
push!(ct::Accumulator, x, a::Number) = inc!(ct, x, a)
80+
Base.push!(ct::Accumulator, x) = inc!(ct, x)
81+
Base.push!(ct::Accumulator, x, a::Number) = inc!(ct, x, a)
8282

8383
# To remove ambiguities related to Accumulator now being a subtype of AbstractDict
84-
push!(ct::Accumulator, x::Pair) = inc!(ct, x)
85-
84+
Base.push!(ct::Accumulator, x::Pair) = inc!(ct, x)
8685

8786

8887
"""
@@ -101,15 +100,15 @@ dec!(ct::Accumulator{T,V}, x) where {T,V} = dec!(ct, x, one(V))
101100
Merges the other counters into `ctl`,
102101
summing the counts for all elements.
103102
"""
104-
function merge!(ct::Accumulator, other::Accumulator)
103+
function Base.merge!(ct::Accumulator, other::Accumulator)
105104
for (x, v) in other
106105
inc!(ct, x, v)
107106
end
108107
return ct
109108
end
110109

111110

112-
function merge!(ct1::Accumulator, others::Accumulator...)
111+
function Base.merge!(ct1::Accumulator, others::Accumulator...)
113112
for ct in others
114113
merge!(ct1,ct)
115114
end
@@ -124,7 +123,7 @@ Creates a new counter with total counts equal to the sum of the counts in the co
124123
125124
See also merge!
126125
"""
127-
function merge(ct1::Accumulator, others::Accumulator...)
126+
function Base.merge(ct1::Accumulator, others::Accumulator...)
128127
ct = copy(ct1)
129128
merge!(ct,others...)
130129
end

src/balanced_tree.jl

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ mutable struct BalancedTree23{K, D, Ord <: Ordering}
145145
end
146146

147147

148-
149-
150148
## Function cmp2 checks a tree node with two children
151149
## against a given key, and returns 1 if the given key is
152150
## less than the node's splitkey or 2 else. Special case
@@ -160,7 +158,6 @@ end
160158
end
161159

162160

163-
164161
@inline function cmp2_leaf(o::Ordering,
165162
treenode::TreeNode,
166163
k)
@@ -169,7 +166,6 @@ end
169166
end
170167

171168

172-
173169
## Function cmp3 checks a tree node with three children
174170
## against a given key, and returns 1 if the given key is
175171
## less than the node's splitkey1, 2 if the key is greater than or
@@ -193,7 +189,6 @@ end
193189
end
194190

195191

196-
197192
## Function cmp2le checks a tree node with two children
198193
## against a given key, and returns 1 if the given key is
199194
## less than or equal to the node's splitkey or 2 else. Special case
@@ -214,8 +209,6 @@ end
214209
end
215210

216211

217-
218-
219212
## Function cmp3le checks a tree node with three children
220213
## against a given key, and returns 1 if the given key is
221214
## less than or equal to the node's splitkey1, 2 if less than or equal
@@ -239,11 +232,10 @@ end
239232
end
240233

241234

242-
243235
## The empty! function deletes all data in the balanced tree.
244236
## Therefore, it invalidates all indices.
245237

246-
function empty!(t::BalancedTree23)
238+
function Base.empty!(t::BalancedTree23)
247239
resize!(t.data,2)
248240
initializeData!(t.data)
249241
resize!(t.tree,1)
@@ -293,7 +285,6 @@ function findkey(t::BalancedTree23, k)
293285
end
294286

295287

296-
297288
## The findkeyless function finds the index of a (key,data) pair in the tree that
298289
## with the greatest key that is less than the given key. If there is no
299290
## key less than the given key, then it returns 1 (the before-start node).
@@ -318,7 +309,6 @@ function findkeyless(t::BalancedTree23, k)
318309
end
319310

320311

321-
322312
## The following are helper routines for the insert! and delete! functions.
323313
## They replace the 'parent' field of either an internal tree node or
324314
## a data node at the bottom tree level.
@@ -337,8 +327,6 @@ function replaceparent!(tree::Array{TreeNode{K},1}, whichind::Int, newparent::In
337327
end
338328

339329

340-
341-
342330
## Helper function for either grabbing a brand new location in a
343331
## array (if there are no free locations) or else grabbing a free
344332
## location and marking it as used. The return value is the
@@ -355,7 +343,6 @@ function push_or_reuse!(a::Vector, freelocs::Array{Int,1}, item)
355343
end
356344

357345

358-
359346
## Function insert! inserts a new data item into the tree.
360347
## The arguments are the (K,D) pair to insert.
361348
## The return values are a bool and an index. The
@@ -367,7 +354,7 @@ end
367354
## done whether the iterm
368355
## is already in the tree, so insertion of a new item always succeeds.
369356

370-
function insert!(t::BalancedTree23{K,D,Ord}, k, d, allowdups::Bool) where {K,D,Ord <: Ordering}
357+
function Base.insert!(t::BalancedTree23{K,D,Ord}, k, d, allowdups::Bool) where {K,D,Ord <: Ordering}
371358

372359
## First we find the greatest data node that is <= k.
373360
leafind, exactfound = findkey(t, k)
@@ -544,8 +531,6 @@ function insert!(t::BalancedTree23{K,D,Ord}, k, d, allowdups::Bool) where {K,D,O
544531
end
545532

546533

547-
548-
549534
## nextloc0: returns the next item in the tree according to the
550535
## sort order, given an index i (subscript of t.data) of a current
551536
## item.
@@ -676,7 +661,7 @@ endloc(t::BalancedTree23) = prevloc0(t,2)
676661

677662
## delete! routine deletes an entry from the balanced tree.
678663

679-
function delete!(t::BalancedTree23{K,D,Ord}, it::Int) where {K,D,Ord<:Ordering}
664+
function Base.delete!(t::BalancedTree23{K,D,Ord}, it::Int) where {K,D,Ord<:Ordering}
680665

681666
## Put the cell indexed by 'it' into the deletion list.
682667
##

src/circ_deque.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Base.isempty(D::CircularDeque) = D.n == 0
3737
3838
Get the item at the front of the queue.
3939
"""
40-
@inline function first(D::CircularDeque)
40+
@inline function Base.first(D::CircularDeque)
4141
@boundscheck D.n > 0 || throw(BoundsError())
4242
return @inbounds D.buffer[D.first]
4343
end
@@ -47,7 +47,7 @@ end
4747
4848
Get the item from the back of the queue.
4949
"""
50-
@inline function last(D::CircularDeque)
50+
@inline function Base.last(D::CircularDeque)
5151
@boundscheck D.n > 0 || throw(BoundsError())
5252
return @inbounds D.buffer[D.last]
5353
end
@@ -74,7 +74,7 @@ end
7474
7575
Add an element to the front.
7676
"""
77-
@inline function pushfirst!(D::CircularDeque, v)
77+
@inline function Base.pushfirst!(D::CircularDeque, v)
7878
@boundscheck D.n < D.capacity || throw(BoundsError())
7979
D.n += 1
8080
tmp = D.first - 1
@@ -88,7 +88,7 @@ end
8888
8989
Remove the element at the front.
9090
"""
91-
@inline Base.@propagate_inbounds function popfirst!(D::CircularDeque)
91+
@inline Base.@propagate_inbounds function Base.popfirst!(D::CircularDeque)
9292
v = first(D)
9393
D.n -= 1
9494
tmp = D.first + 1
@@ -112,7 +112,7 @@ end
112112
end
113113

114114
# Iteration via getindex
115-
@inline function iterate(d::CircularDeque, i = 1)
115+
@inline function Base.iterate(d::CircularDeque, i = 1)
116116
i == d.n + 1 ? nothing : (_unsafe_getindex(d, i), i+1)
117117
end
118118

src/circular_buffer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ end
9696
9797
Remove the element from the front of the `CircularBuffer`.
9898
"""
99-
function popfirst!(cb::CircularBuffer)
99+
function Base.popfirst!(cb::CircularBuffer)
100100
@boundscheck (cb.length == 0) && throw(ArgumentError("array must be non-empty"))
101101
i = cb.first
102102
cb.first = (cb.first + 1 > cb.capacity ? 1 : cb.first + 1)
@@ -110,7 +110,7 @@ end
110110
Insert one or more items at the beginning of CircularBuffer
111111
and overwrite back if full.
112112
"""
113-
function pushfirst!(cb::CircularBuffer, data)
113+
function Base.pushfirst!(cb::CircularBuffer, data)
114114
# if full, decrement and overwrite, otherwise pushfirst
115115
cb.first = (cb.first == 1 ? cb.capacity : cb.first - 1)
116116
if length(cb) < cb.capacity

0 commit comments

Comments
 (0)