Skip to content

Home > @esengine/ecs-framework-monorepo > Bits

Bits class

64位位集合类,用于高效的位操作 支持最多64个位的设置、清除、查询和逻辑运算

Signature:

typescript
export declare class Bits

Constructors

Constructor

Modifiers

Description

(constructor)(initialValue)

构造函数,创建位集合

Methods

Method

Modifiers

Description

and(other)

与另一个位集合执行按位与操作

cardinality()

计算设置为1的位数

clear(index)

清除指定位为0

clearAll()

清除所有位为0

clone()

创建当前位集合的深拷贝

containsAll(other)

检查是否包含另一个位集合的所有位

copyFrom(other)

从另一个位集合复制值

equals(other)

检查是否与另一个位集合相等

excludes(other)

检查是否与另一个位集合没有交集

fromBinaryString(binaryString)

static

从二进制字符串创建位集合

fromHexString(hexString)

static

从十六进制字符串创建位集合

get(index)

获取指定位的值

getHighestBitIndex()

获取最高位设置位的索引

getLowestBitIndex()

获取最低位设置位的索引

getValue()

获取内部的64位掩码数据

intersects(other)

检查是否与另一个位集合有交集

isEmpty()

检查位集合是否为空

not(maxBits)

执行按位取反操作

or(other)

与另一个位集合执行按位或操作

set(index)

设置指定位为1

setValue(value)

设置位集合的值

toBinaryString(maxBits)

将位集合转换为二进制字符串

toHexString()

将位集合转换为十六进制字符串

toString()

将位集合转换为可读字符串

xor(other)

与另一个位集合执行按位异或操作

基于 MIT 许可证发布