diff options
author | Russ Cox <rsc@golang.org> | 2009-11-20 13:11:42 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-11-20 13:11:42 -0800 |
commit | 02e6f62b7f55e735ee0d6cc4ba9403c54c1d4488 (patch) | |
tree | a74a55b4b27e5db38deaf92b44ad97c7b1f03200 /test/bench/binary-tree.go | |
parent | 0bc379728beb1873025bafd5a217250795a89ecc (diff) | |
download | golang-02e6f62b7f55e735ee0d6cc4ba9403c54c1d4488.tar.gz |
gofmt -r 'α[β:len(α)] -> α[β:]' -w test/bench
except chameneosredux which i know is being edited
require gofmt for test/bench
R=r
http://codereview.appspot.com/157110
Diffstat (limited to 'test/bench/binary-tree.go')
-rw-r--r-- | test/bench/binary-tree.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/test/bench/binary-tree.go b/test/bench/binary-tree.go index 827fe463e..88497d490 100644 --- a/test/bench/binary-tree.go +++ b/test/bench/binary-tree.go @@ -44,15 +44,15 @@ import ( var n = flag.Int("n", 15, "depth") type Node struct { - item int; - left, right *Node; + item int; + left, right *Node; } -func bottomUpTree(item, depth int) *Node { +func bottomUpTree(item, depth int) *Node { if depth <= 0 { return &Node{item: item} } - return &Node{ item, bottomUpTree(2*item-1, depth-1), bottomUpTree(2*item, depth-1) } + return &Node{item, bottomUpTree(2*item-1, depth-1), bottomUpTree(2*item, depth-1)}; } func (n *Node) itemCheck() int { @@ -62,13 +62,13 @@ func (n *Node) itemCheck() int { return n.item + n.left.itemCheck() - n.right.itemCheck(); } -const minDepth = 4; +const minDepth = 4 func main() { flag.Parse(); maxDepth := *n; - if minDepth + 2 > *n { + if minDepth+2 > *n { maxDepth = minDepth + 2 } stretchDepth := maxDepth + 1; @@ -78,13 +78,13 @@ func main() { longLivedTree := bottomUpTree(0, maxDepth); - for depth := minDepth; depth <= maxDepth; depth+=2 { - iterations := 1 << uint(maxDepth - depth + minDepth); + for depth := minDepth; depth <= maxDepth; depth += 2 { + iterations := 1 << uint(maxDepth-depth+minDepth); check = 0; for i := 1; i <= iterations; i++ { - check += bottomUpTree(i,depth).itemCheck(); - check += bottomUpTree(-i,depth).itemCheck(); + check += bottomUpTree(i, depth).itemCheck(); + check += bottomUpTree(-i, depth).itemCheck(); } fmt.Printf("%d\t trees of depth %d\t check: %d\n", iterations*2, depth, check); } |