Useful data structure
Set
Go lang에는 set이 없지만 비슷하게 만들어 사용할 수 있다.
func setAdd(s map[int]bool, v int) map[int]bool {
s[v] = true
return s
}
func main() {
s := make(map[int]bool)
s = setAdd(s, 1)
s = setAdd(s, 2)
s = setAdd(s, 3)
s = setAdd(s, 2)
fmt.Println(s)
delete(s, 3)
fmt.Println(s)
}map[1:true 2:true 3:true]
map[1:true 2:true]Slice of map
Last updated
Was this helpful?