Library for storage of packed unsigned booleans.
uint256 internal constant NOT_FOUND = type(uint256).maxThe constant returned when a bitmap scan does not find a result.
struct Bitmap {
mapping(uint256 => uint256) map;
}A bitmap in storage.
function get(Bitmap storage bitmap, uint256 index)
internal
view
returns (bool isSet)Returns the boolean value of the bit at index in bitmap.
function set(Bitmap storage bitmap, uint256 index) internalUpdates the bit at index in bitmap to true.
function unset(Bitmap storage bitmap, uint256 index) internalUpdates the bit at index in bitmap to false.
function toggle(Bitmap storage bitmap, uint256 index)
internal
returns (bool newIsSet)Flips the bit at index in bitmap.
Returns the boolean result of the flipped bit.
function setTo(Bitmap storage bitmap, uint256 index, bool shouldSet)
internalUpdates the bit at index in bitmap to shouldSet.
function setBatch(Bitmap storage bitmap, uint256 start, uint256 amount)
internalConsecutively sets amount of bits starting from the bit at start.
function unsetBatch(Bitmap storage bitmap, uint256 start, uint256 amount)
internalConsecutively unsets amount of bits starting from the bit at start.
function popCount(Bitmap storage bitmap, uint256 start, uint256 amount)
internal
view
returns (uint256 count)Returns number of set bits within a range by
scanning amount of bits starting from the bit at start.
function findLastSet(Bitmap storage bitmap, uint256 upTo)
internal
view
returns (uint256 setBitIndex)Returns the index of the most significant set bit in [0..upTo].
If no set bit is found, returns NOT_FOUND.
function findFirstUnset(Bitmap storage bitmap, uint256 begin, uint256 upTo)
internal
view
returns (uint256 unsetBitIndex)Returns the index of the least significant unset bit in [begin..upTo].
If no unset bit is found, returns NOT_FOUND.