我有一个Node这样的结构类型:
package tree
// Enum for node category
type Level int32
const (
Leaf Level = iota + 1
Branch
Root
)
type Node struct {
Children []*Node
Parent *Node
X float32
Y float32
Z float32
Dim float32
Category Level
LeafPenetration float32 // Needed only if category is "Leaf"
RootPadDim float32 // Needed only if category is "Root"
}
我有两个字段Node是可选的,仅根据category字段需要:
leafPenetration float32 // Needed only if category is "Leaf"
rootPadDim float32 // Needed only if category is "Root"
目前的Node实施还好吗?结构类型中此类可选/条件字段的最佳实践是什么?
蓝山帝景
小怪兽爱吃肉
吃鸡游戏
相关分类