本文整理匯總了Golang中code/google/com/p/go-tour/tree.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
if Same(tree.New(1), tree.New(1)) {
fmt.Println("Same!")
} else {
fmt.Println("not Same!")
}
}
示例2: main
func main() {
if Same(tree.New(1), tree.New(2)) {
fmt.Println("Yay!")
} else {
fmt.Println("Nay!")
}
}
示例3: main
func main() {
t1 := tree.New(1)
t2 := tree.New(1)
fmt.Println(Same(t1, t2))
}
示例4: C70
// C70 ...
func C70(opts Options, args []string) int {
t1 := tree.New(1)
t2 := tree.New(1)
fmt.Println(t1)
fmt.Println(t2)
fmt.Println(same(t1, t2))
return 0
}
示例5: main
func main() {
// ch := make(chan int)
// go Walk(tree.New(1), ch)
// for i := 0; i < 10; i++ {
// fmt.Println(<-ch)
// }
fmt.Println(Same(tree.New(1), tree.New(1)))
fmt.Println(Same(tree.New(1), tree.New(2)))
}
示例6: main
func main() {
ch := make(chan int)
go Walk(tree.New(1), ch)
for i := range ch {
fmt.Println(i)
}
fmt.Println(Same(tree.New(1), tree.New(1)))
fmt.Println(Same(tree.New(1), tree.New(2)))
}
示例7: TestSame
func TestSame(t *testing.T) {
if !Same(tree.New(1), tree.New(1)) {
t.Errorf("Expect tree.New(1) is the same with tree.New(1)")
}
if Same(tree.New(1), tree.New(2)) {
t.Errorf("Expect tree.New(1) is not the same with tree.New(2)")
}
}
示例8: main
func main() {
ch := make(chan int)
go Walk(tree.New(1), ch)
for i := 0; i < 10; i++ {
print(<-ch, " ")
}
print("\n")
println(Same(tree.New(1), tree.New(1)),
Same(tree.New(2), tree.New(1)))
}
示例9: main
func main() {
ch := make(chan int)
go Walk(tree.New(1), ch)
for i := 0; i < 10; i++ {
fmt.Println(<-ch)
}
fmt.Println(Same(tree.New(1), tree.New(1)))
fmt.Println(Same(tree.New(1), tree.New(2)))
}
示例10: main
func main() {
if !Same(tree.New(1), tree.New(1)) {
fmt.Println("fail!! 1 && 1")
return
}
if Same(tree.New(1), tree.New(2)) {
fmt.Println("fail!! 1 && 2")
return
}
fmt.Println("all succeed!")
}
示例11: main
func main() {
ch := make(chan int)
go Walk(tree.New(1), ch)
for n := range ch {
print(n, " ")
}
println()
println(Same(tree.New(1), tree.New(1)))
println(Same(tree.New(1), tree.New(2)))
}
示例12: main
func main() {
t1 := tree.New(1)
/*
ch := make(chan int, 10)
go Walk(t1, ch)
for val := range(ch){
fmt.Println(val)
}
*/
fmt.Println(Same(t1, tree.New(1)))
fmt.Println(Same(t1, tree.New(2)))
}
示例13: main
func main() {
t := tree.New(1)
t2 := tree.New(1)
fmt.Println(t)
fmt.Println(t2)
c := make(chan int)
go Walk(t, c)
for i := 0; i < 10; i++ {
fmt.Println(<-c)
}
fmt.Println(Same(t, t2))
}
示例14: page68_Exercise_EquivalentBinaryTrees
func page68_Exercise_EquivalentBinaryTrees() {
// test Walk
/*
ch := make(chan int)
go Walk(tree.New(1), ch)
for i := 0; i < 10; i++ {
fmt.Println(<-ch)
}
*/
fmt.Println(Same(tree.New(1), tree.New(1)))
fmt.Println(Same(tree.New(1), tree.New(2)))
}
示例15: Exercise11
func Exercise11() {
// Uncomment to test Walk
// ch := make(chan int)
// go Walk(tree.New(1), ch)
//
// for v := range ch {
// fmt.Printf("%d\n", v)
// }
fmt.Printf("tree.New(1) == tree.New(1) is %t\n", Same(tree.New(1), tree.New(1)))
fmt.Printf("tree.New(1) == tree.New(2) is %t\n", Same(tree.New(1), tree.New(2)))
}