Skip to content

Commit eb3071f

Browse files
committed
Add BinaryMinMaxHeap constructor for combined type and data
1 parent 17c1578 commit eb3071f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/heaps/minmax_heap.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ mutable struct BinaryMinMaxHeap{T} <: AbstractMinMaxHeap{T}
99

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

12-
function BinaryMinMaxHeap(xs::AbstractVector{T}) where {T}
12+
function BinaryMinMaxHeap{T}(xs::AbstractVector{T}) where {T}
1313
valtree = _make_binary_minmax_heap(xs)
1414
new{T}(valtree)
1515
end
1616
end
1717

18+
BinaryMinMaxHeap(xs::AbstractVector{T}) where T = BinaryMinMaxHeap{T}(xs)
19+
1820
################################################
1921
#
2022
# core implementation

test/test_minmax_heap.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using Base.Order: Forward, Reverse
88
vs = [10, 4, 6, 1, 16, 2, 20, 17, 13, 5]
99

1010
BinaryMinMaxHeap{Int}()
11-
11+
BinaryMinMaxHeap{Int}(vs)
1212
BinaryMinMaxHeap(vs)
1313

1414
@test true

0 commit comments

Comments
 (0)