File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed
Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,16 @@ import ..EquationModule:
1818
1919Count the number of nodes in the tree.
2020"""
21- count_nodes
21+ function count_nodes (tree:: AbstractNode ; break_sharing= Val (false ))
22+ return tree_mapreduce (
23+ _ -> 1 ,
24+ + ,
25+ tree,
26+ Int64;
27+ f_on_shared= (c, is_shared) -> is_shared ? 0 : c,
28+ break_sharing,
29+ )
30+ end
2231
2332"""
2433 count_depth(tree::AbstractNode)::Int
Original file line number Diff line number Diff line change 128128function allocate_id_map (tree:: AbstractNode , :: Type{RT} ) where {RT}
129129 d = Dict {UInt,RT} ()
130130 # Preallocate maximum storage (counting with duplicates is fast)
131- N = count_nodes (tree; break_sharing= Val (true ))
131+ N = length (tree; break_sharing= Val (true ))
132132 sizehint! (d, N)
133133 return d
134134end
@@ -318,17 +318,6 @@ function count(
318318 ) + init
319319end
320320
321- function count_nodes (tree:: AbstractNode ; break_sharing= Val (false ))
322- return tree_mapreduce (
323- _ -> 1 ,
324- + ,
325- tree,
326- Int64;
327- f_on_shared= (c, is_shared) -> is_shared ? 0 : c,
328- break_sharing,
329- )
330- end
331-
332321function sum (
333322 f:: F ,
334323 tree:: AbstractNode ;
You can’t perform that action at this time.
0 commit comments