Skip to content

Latest commit

 

History

History
174 lines (77 loc) · 5.16 KB

bit_vector.md

File metadata and controls

174 lines (77 loc) · 5.16 KB

Module 0x1::bit_vector

Struct BitVector

struct BitVector has copy, drop, store

Constants

The provided index is out of bounds

const EINDEX: u64 = 131072;

An invalid length of bitvector was given

const ELENGTH: u64 = 131073;

The maximum allowed bitvector size

const MAX_SIZE: u64 = 1024;

const WORD_SIZE: u64 = 1;

Function new

public fun new(length: u64): bit_vector::BitVector

Function set

Set the bit at bit_index in the bitvector regardless of its previous state.

public fun set(bitvector: &mut bit_vector::BitVector, bit_index: u64)

Function unset

Unset the bit at bit_index in the bitvector regardless of its previous state.

public fun unset(bitvector: &mut bit_vector::BitVector, bit_index: u64)

Function shift_left

Shift the bitvector left by amount. If amount is greater than the bitvector's length the bitvector will be zeroed out.

public fun shift_left(bitvector: &mut bit_vector::BitVector, amount: u64)

Function is_index_set

Return the value of the bit at bit_index in the bitvector. true represents "1" and false represents a 0

public fun is_index_set(bitvector: &bit_vector::BitVector, bit_index: u64): bool

Function length

Return the length (number of usable bits) of this bitvector

public fun length(bitvector: &bit_vector::BitVector): u64

Function longest_set_sequence_starting_at

Returns the length of the longest sequence of set bits starting at (and including) start_index in the bitvector. If there is no such sequence, then 0 is returned.

public fun longest_set_sequence_starting_at(bitvector: &bit_vector::BitVector, start_index: u64): u64

Function shift_left_for_verification_only

#[verify_only]
public fun shift_left_for_verification_only(bitvector: &mut bit_vector::BitVector, amount: u64)