package core:container/bit_array

⌘K
Ctrl+K
or
/

    Index

    Constants (0)

    This section is empty.

    Variables (0)

    This section is empty.

    Procedure Groups (0)

    This section is empty.

    Types

    Bit_Array ¶

    Bit_Array :: struct {
    	bits:         [dynamic]u64,
    	bias:         int,
    	max_index:    int,
    	free_pointer: bool,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    Bit_Array_Iterator ¶

    Bit_Array_Iterator :: struct {
    	array:    ^Bit_Array,
    	word_idx: int,
    	bit_idx:  uint,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    Constants

    This section is empty.

    Variables

    This section is empty.

    Procedures

    clear ¶

    clear :: proc(ba: ^Bit_Array) {…}
     

    Sets all values in the Bit_Array to zero.

    Inputs:
    ba: The target Bit_Array

    create ¶

    create :: proc(max_index: int, min_index: int = 0, allocator := context.allocator) -> (res: ^Bit_Array, ok: bool) #optional_ok {…}
     

    A helper function to create a Bit Array with optional bias, in case your smallest index is non-zero (including negative).

    Allocates (`new(Bit_Array) & make(ba.bits)`)

    Inputs:
    max_index: maximum starting index min_index: minimum starting index (used as a bias) allocator: (default is context.allocator)

    Returns:
    ba: Allocates a bit_Array, backing data is set to max-min / 64 indices, rounded up (eg 65 - 0 allocates for [2]u64).

    destroy ¶

    destroy :: proc(ba: ^Bit_Array) {…}
     

    Deallocates the Bit_Array and its backing storage

    Inputs:
    ba: The target Bit_Array

    get ¶

    get :: proc(ba: ^Bit_Array, #any_int index: uint) -> (res: bool, ok: bool) #optional_ok {…}
     

    Gets the state of a bit in the bit-array

    Inputs:
    ba: Pointer to the Bit_Array index: Which bit in the array

    Returns:
    res: true if the bit at index is set. ok: Whether the index was valid. Returns false if the index is smaller than the bias.

    iterate_by_all ¶

    iterate_by_all :: proc(it: ^Bit_Array_Iterator) -> (set: bool, index: int, ok: bool) {…}
     

    Returns the next bit, including its set-state. ok=false once exhausted

    Inputs:
    it: The iterator that holds the state.

    Returns:
    set: true if the bit at index is set. index: The next bit of the Bit_Array referenced by it. ok: true if the iterator can continue, false if the iterator is done

    iterate_by_set ¶

    iterate_by_set :: proc(it: ^Bit_Array_Iterator) -> (index: int, ok: bool) {…}
     

    Returns the next Set Bit, for example if 0b1010, then the iterator will return index={1, 3} over two calls.

    Inputs:
    it: The iterator that holds the state.

    Returns:
    index: The next set bit of the Bit_Array referenced by it. ok: true if the iterator can continue, false if the iterator is done

    iterate_by_unset ¶

    iterate_by_unset :: proc(it: ^Bit_Array_Iterator) -> (index: int, ok: bool) {…}
     

    Returns the next Unset Bit, for example if 0b1010, then the iterator will return index={0, 2} over two calls.

    Inputs:
    it: The iterator that holds the state.

    Returns:
    index: The next unset bit of the Bit_Array referenced by it. ok: true if the iterator can continue, false if the iterator is done

    make_iterator ¶

    make_iterator :: proc(ba: ^Bit_Array) -> (it: Bit_Array_Iterator) {…}
     

    Wraps a Bit_Array into an Iterator

    Inputs:
    ba: Pointer to the Bit_Array

    Returns:
    it: Iterator struct

    set ¶

    set :: proc(ba: ^Bit_Array, #any_int index: uint, set_to: bool = true, allocator := context.allocator) -> (ok: bool) {…}
     

    Sets the state of a bit in the bit-array

    Conditionally Allocates (Resizes backing data when `index > len(ba.bits)`)

    Inputs:
    ba: Pointer to the Bit_Array index: Which bit in the array set_to: true sets the bit on, false to turn it off allocator: (default is context.allocator)

    Returns:
    ok: Whether the set was successful, false on allocation failure or bad index

    unsafe_get ¶

    unsafe_get :: proc(ba: ^Bit_Array, #any_int index: uint) -> bool {…}
     

    Gets the state of a bit in the bit-array

    Bypasses all Checks

    Inputs:
    ba: Pointer to the Bit_Array index: Which bit in the array

    Returns:
    true if bit is set

    unsafe_set ¶

    unsafe_set :: proc(ba: ^Bit_Array, bit: int) {…}
     

    Sets the state of a bit in the bit-array

    Bypasses all checks

    Inputs:
    ba: Pointer to the Bit_Array index: Which bit in the array

    unsafe_unset ¶

    unsafe_unset :: proc(b: ^Bit_Array, bit: int) {…}
     

    Unsets the state of a bit in the bit-array

    Bypasses all Checks

    Inputs:
    ba: Pointer to the Bit_Array index: Which bit in the array

    unset ¶

    unset :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (ok: bool) {…}
     

    Unsets the state of a bit in the bit-array. (Convienence wrapper for set)

    Conditionally Allocates (Resizes backing data when `index > len(ba.bits)`)

    Inputs:
    ba: Pointer to the Bit_Array index: Which bit in the array allocator: (default is context.allocator)

    Returns:
    ok: Whether the unset was successful, false on allocation failure or bad index

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2023-10 (vendor "odin") Windows_amd64 @ 2023-10-03 21:09:46.864649900 +0000 UTC