Bit 数组
来源:互联网 发布:免费php主机 编辑:程序博客网 时间:2024/06/16 14:12
// An IntSet is a set of small non-negative integers.// Its zero value represents the empty set.type IntSet struct {words []uint64}// Has reports whether the set contains the non-negative value x.func (s *IntSet) Has(x int) bool {word, bit := x/64, uint(x%64)return word < len(s.words) && s.words[word]&(1<<bit) != 0}// Add adds the non-negative value x to the set.func (s *IntSet) Add(x int) {word, bit := x/64, uint(x%64)for word >= len(s.words) {s.words = append(s.words, 0)}s.words[word] |= 1 << bit}// UnionWith sets s to the union of s and t.func (s *IntSet) UnionWith(t *IntSet) {for i, tword := range t.words {if i < len(s.words) {s.words[i] |= tword} else {s.words = append(s.words, tword)}}}
Go语言圣经 gopl.io/ch6/intset
阅读全文
0 0
- Bit数组
- Bit 数组
- BIT树状数组
- 数组模拟bit存储
- 【树状数组(BIT)】
- 树状数组BIT 模板
- 树状数组(BIT)
- Golang 实现Bit数组
- [leetcode] 树状数组 BIT
- 树状数组 BIT
- 树状数组BIT
- BIT树状数组
- 树状数组(BIT)
- 树状数组(BIT)
- 树状数组 BIT
- 树状数组BIT-乒乓比赛
- 模板_树状数组(BIT)
- 一维树状数组BIT
- KETTLE大批量提交数据时出现丢失问题
- 较为全面的ADC驱动
- 分布式与集群的区别
- mousedown、mouseup与click
- 【banner】介绍一个纯CSS3做的轮播图
- Bit 数组
- 数据在计算机中的表示方法
- Google发现的十大真理
- Unity制作Roll-a-Ball游戏
- 微信支付开发教程
- the difference between shutdown, poweroff, halt and reboot
- 获取类上的注解的相关参数
- SQL 取两时间之差和常用时间格式
- Java8 Lambda表达式之比较器