From a73dd096b45e629d65f35bf43e412b7ad70150d7 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Wed, 6 Mar 2019 11:46:38 +0100 Subject: [PATCH] improved docstrings --- src/RootedTrees.jl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/RootedTrees.jl b/src/RootedTrees.jl index c1345db9..0d8092ab 100644 --- a/src/RootedTrees.jl +++ b/src/RootedTrees.jl @@ -3,7 +3,7 @@ module RootedTrees using LinearAlgebra -import Base: show, isless, ==, iterate +import Base: show, isless, ==, iterate, copy export RootedTree, RootedTreeIterator @@ -35,6 +35,8 @@ function RootedTree(level_sequence::AbstractVector) end #TODO: Validate rooted tree in constructor? +copy(t::RootedTree) = RootedTree(copy(t.level_sequence)) + # #function RootedTree(sequence::Vector{T}, valid::Bool) # function RootedTree(sequence::Array{T,1}) @@ -114,7 +116,7 @@ Returns a new tree using the canonical representation of the rooted tree `t`, i.e. the one with lexicographically biggest level sequence. """ function canonical_representation(t::RootedTree) - canonical_representation!(RootedTree(copy(t.level_sequence))) + canonical_representation!(copy(t)) end @@ -122,7 +124,9 @@ end """ RootedTreeIterator{T<:Integer} -Iterator over all rooted trees of given `order`. +Iterator over all rooted trees of given `order`. The returned trees are views to +an internal tree modified during the iteration. If the returned trees shall be +stored or modified during the iteration, a `copy` has to be made. """ struct RootedTreeIterator{T<:Integer} order::T