Skip to content

Commit

Permalink
Fixed print & show bug (#8)
Browse files Browse the repository at this point in the history
Fixed bug for print & show methods in which there was a typo referring to a variable `string_list` instead of `str_lst`. Also adjusted tabbing in show method.
  • Loading branch information
p-casgrain committed Jul 7, 2021
1 parent 4a1c5da commit a9565fe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -400,28 +400,29 @@ end

## Print and Show methods

function Base.print(io::IO,tree::AVLTree)
function Base.print(io::IO,tree::AVLTree{K,D}) where {K,D}
str_lst = Vector{String}()
for (k,v) in Base.Iterators.take(iterate(tree),10)
for (k,v) in Base.Iterators.take(tree,10)
push!(str_lst,"$k => $v")
end
print(io,"AVLTree(")
print(io,"AVLTree{$K,$D}(")
print(io,join(str_lst,", "))
length(str_lst) == 10 && print(io,", ⋯ ")
print(io,")")
end

function Base.show(io::IO, ::MIME"text/plain", tree::AVLTree{K,D}) where {K,D}
str_lst = Vector{String}()
indent_str = " "
for (k,v) in Base.Iterators.take(tree,10)
push!(str_lst," $k => $v")
push!(str_lst,indent_str*"$k => $v")
end
if length(str_lst)>0
print(io,"AVLTree{$K,$D} with $(length(str_lst)) entries:\n")
print(io,join(str_lst,"\n"))
else
print(io,"AVLTree{$K,$D}()")
end
length(str_list) == 10 && print(io,"\n")
length(str_lst) == 10 && print(io,"\n",indent_str*"⋮ => ⋮ \n")
end

0 comments on commit a9565fe

Please sign in to comment.