Module bones_lib::ecs::bitset

Expand description

Bitset implementation.

Bitsets are powered by the bitset_core crate.

A Bones bitset is a vector of 32-byte sectors. The size of a bitset can be controlled by the keysize* features (note that they are all mutually exclusive with each other). The keysize is exponentially correlated to the number of bits, or entities, that the set can track; where the number of bits equals two raised to the power of keysize. Below are the available keysizes and the size of their resulting bitsets.

KeysizeBit CountSectorsMemory
324 billion16 million512 MB
2416 million655362 MB
201 million4096128 KB
16655362568 KB
12409616512 B
1010244128 B

Keysize (K) refers to the name of the feature. A keysize of 16 refers to the keysize16 feature.

Bit Count is the total number of bits in the bitset (2^K). Due to the nature of binary numbers this means that a value with more than K bits should not be used to index into the bitset since e.g. u16::MAX is the index of the last bit in a keysize16 bitset.

Sectors is the number of sub-arrays within the bitset Vec. Sectors are 256 bits as they are comprised of 8 u32s. Note that SIMD instructions process 256 bits/entities at a time.

Memory is the total amount of memory that the bitset will occupy.

Macros§

  • Shorthand for combining bitsets with bit_or.
  • Shorthand for setting bits on the bitset container.
  • Implements the BitSet trait members for your type through DerefMut.

Structs§

  • BitSet formatter.
  • The type of bitsets used to track entities in component storages. Mostly used to create caches.

Constants§

Traits§

Functions§

  • Creates a bitset big enough to contain the index of each entity. Mostly used to create caches.