本文整理汇总了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)))
}