以遍历Block结构为例,Block结构如下:

type Block struct {
    Inside   bool
    Nest     int
    Boundary bool
    Incise   []*Block
}

可以看到Block中包含一个[]*Block类型的属性,在Block中,若Inside为true则说明Incise不为空。我们的目的是遍历一个[]Block数组,若其Incise有值则继续向下遍历。

遍历代码如下:

func TraversingCubes(cubes []*blockCut.Block) {for _,cube:= range cubes{
        if cube.Inside==true {
            fmt.printf(cube)
        }else {
            cubes = cube.Incise
            TraversingCubes(cubes)
        }
    }
    return
}

 


 
                    
            
                

相关文章:

  • 2022-02-08
  • 2021-06-06
  • 2021-12-11
  • 2022-12-23
  • 2021-09-27
  • 2021-08-05
  • 2021-11-01
  • 2022-01-01
猜你喜欢
  • 2022-12-23
  • 2022-02-12
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2021-04-25
  • 2022-12-23
相关资源
相似解决方案