Skip to content

Commit

Permalink
Add BinaryMinMaxHeap constructor for combined type and data
Browse files Browse the repository at this point in the history
  • Loading branch information
milesfrain committed Dec 3, 2019
1 parent 17c1578 commit eb3071f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/heaps/minmax_heap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ mutable struct BinaryMinMaxHeap{T} <: AbstractMinMaxHeap{T}

BinaryMinMaxHeap{T}() where {T} = new{T}(Vector{T}())

function BinaryMinMaxHeap(xs::AbstractVector{T}) where {T}
function BinaryMinMaxHeap{T}(xs::AbstractVector{T}) where {T}
valtree = _make_binary_minmax_heap(xs)
new{T}(valtree)
end
end

BinaryMinMaxHeap(xs::AbstractVector{T}) where T = BinaryMinMaxHeap{T}(xs)

################################################
#
# core implementation
Expand Down
2 changes: 1 addition & 1 deletion test/test_minmax_heap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using Base.Order: Forward, Reverse
vs = [10, 4, 6, 1, 16, 2, 20, 17, 13, 5]

BinaryMinMaxHeap{Int}()

BinaryMinMaxHeap{Int}(vs)
BinaryMinMaxHeap(vs)

@test true
Expand Down

0 comments on commit eb3071f

Please sign in to comment.