Skip to content

Commit 11d92e7

Browse files
committed
Fix Julia v1.0
Base.popat! requires Julia v1.5. So define and export it only if it's not defined already. We should consider not exporting it or instead defining Compat.popat!, as simply exporting it may be breaking. JuliaLang/julia#42080
1 parent 18075b9 commit 11d92e7

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/DataStructures.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ module DataStructures
55
isbitsunion, isiterable, dict_with_eltype, KeySet, Callable, _tablesz,
66
findnextnot, unsafe_getindex, unsafe_setindex!, peek
77

8+
if !isdefined(Base, :popat!)
9+
export popat!
10+
end
11+
812

913
using Compat # Provides Base.Order.ReverseOrdering(). May remove this line with julia 1.4
1014
using OrderedCollections

src/deprecations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ Base.@deprecate_binding IntDisjointSets IntDisjointSet
1313
@deprecate enqueue!(q::PriorityQueue, k, v) Base.push!(q, k=>v)
1414
@deprecate dequeue!(q::Queue) Base.popfirst!(q)
1515
@deprecate dequeue!(q::PriorityQueue) Base.popfirst!(q).first # maybe better: `val, _ = popfirst!(pq)`
16-
@deprecate dequeue!(q::PriorityQueue, x) Base.popat!(q, x).first
16+
@deprecate dequeue!(q::PriorityQueue, x) popat!(q, x).first
1717
@deprecate dequeue_pair!(q::PriorityQueue) Base.popfirst!(q)
18-
@deprecate dequeue_pair!(q::PriorityQueue, key) Base.popat!(q, key)
18+
@deprecate dequeue_pair!(q::PriorityQueue, key) popat!(q, key)

src/priorityqueue.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,13 @@ function Base.popfirst!(pq::PriorityQueue)
274274
return x
275275
end
276276

277-
function Base.popat!(pq::PriorityQueue, key)
277+
if isdefined(Base, :popat!)
278+
Base.popat!(pq::PriorityQueue, key) = _popat!(pq, key)
279+
else
280+
popat!(pq::PriorityQueue, key) = _popat!(pq, key)
281+
end
282+
283+
function _popat!(pq::PriorityQueue, key)
278284
idx = pq.index[key]
279285
force_up!(pq, idx)
280286
popfirst!(pq)

0 commit comments

Comments
 (0)