fix overshoot and optimize better

This commit is contained in:
Barak Michener 2014-08-06 03:20:33 -04:00
parent 09244ddd38
commit 24f57df859
4 changed files with 21 additions and 10 deletions

View file

@ -154,11 +154,14 @@ func Next(it Iterator) (Value, bool) {
}
// Height is a convienence function to measure the height of an iterator tree.
func Height(it Iterator) int {
func Height(it Iterator, until Type) int {
if it.Type() == until {
return 1
}
subs := it.SubIterators()
maxDepth := 0
for _, sub := range subs {
h := Height(sub)
h := Height(sub, until)
if h > maxDepth {
maxDepth = h
}