Abit

test

Use Erlang's :atomics as a mutable bit array or as an array of packed N-bit counters.

See the API documentation on HexDocs.

Installation

Abit requires Elixir 1.14 or later and OTP 25 or later.

Add abit to your list of dependencies in mix.exs:

def deps do
[
{:abit, "~> 1.0"}
]
end

API summary

Abit indexes bits and packed counters from zero. Raw :atomics indexes, including the index accepted by Abit.Counter.get_all_at_atomic/2, start from one.

Operations that write to an :atomics reference mutate it in place. See the full API documentation for examples and return values.

Abit - use :atomics as a bit array

Abit.Atomics - utility functions for working with Erlang's :atomics

Abit.Counter - use :atomics as an array of N-bit counters

Abit.Bitmask - helper functions for bitmasks

Population counts and Hamming distances cover only the lowest 64 bits. Indexed operations can address higher bit positions, while to_list/2 uses its explicit size argument.

License

Abit is MIT licensed.