跳到主要内容

bitset

简介

用于储存位的容器

组件接口

bitset.gs

函数原型函数作用
int size(BitSet self)获取BitSet包含的位长度
bool get_bit(BitSet self, int index)获取BitSet指定位置的位值
void set_bit(BitSet self, int index, bool mark)设置BitSet指定位置的位值
bool flip(BitSet self, int index)翻转BitSet指定位置的位值
BitSet and(BitSet self, BitSet other)将两个BitSet进行与操作,产生一个新的BitSet,其长度为两个BitSet中较小的一个
BitSet or(BitSet self, BitSet other)将两个BitSet进行或操作,产生一个新的BitSet,其长度为两个BitSet中较小的一个
BitSet xor(BitSet self, BitSet other)将两个BitSet进行异或操作,产生一个新的BitSet,其长度为两个BitSet中较小的一个
BitSet and_not(BitSet self, BitSet other)将两个BitSet进行与非操作,产生一个新的BitSet,其长度为两个BitSet中较小的一个
bool empty(BitSet self)检查BitSet的所有位是否均为 0
void reset(BitSet self)重置BitSet的所有位为 0
void set_range(BitSet self, int start, int end, bool mark)设置BitSet的指定范围的位值
void flip_range(BitSet self, int start, int end)翻转BitSet的指定范围的位值
BitSet slices(BitSet self, int start, int end)获取BitSet的指定范围的位值
void set_all(BitSet self, bool mark)设置BitSet的所有位为指定值
void flip_all(BitSet self)翻转BitSet的所有位
BitSet clone(BitSet self)克隆BitSet实例
buffer data_raw(BitSet self)获取BitSet的底层数据原件(一般情况下不应该使用此接口,另优先考虑使用data_dup)
buffer data_dup(BitSet self)获取BitSet的底层数据副本(一般情况下不应该使用此接口)

样例

public void pkg_sample()
{
write("sample");
}