我想创建一个动态初始化的位图数据结构。我正在尝试使用golang地图:
type Register map[bool]*[]bool
我初始化映射的方式是:
register := make(Register) register[true] := make(*[]bool, len(arr)) // arr is the array for which i want to create the bitmap
这显然会产生错误编译问题:
error: cannot make type *[]bool
我也尝试过使用指针语法:
register[true] = &(make([]bool, len(arr)))
这给了我一个错误:
cannot take the address of make([]bool, len(arr))
我希望映射值的原因是,写回映射的过程保持理智和就地。*[]bool
虽然go不会抱怨,因此它是一种有效的类型。
如果它有效,那么以我想要的方式使用它的idomatic方式是什么。如果不是,那么替代方法是什么?map[bool]*[]bool
UYOU
凤凰求蛊
相关分类