BitArray

High-level bit array handling utilities.

Overview

Typical use cases:

  • Handling bit array manipulation and storage

Header

<RaeptorCogs/BitArray.hpp>

Metadata

Author

Estorc

Version

v1.0

Copyright

Copyright (c) 2025 Estorc MIT License.

Classes

Classes

Class

Description

RaeptorCogs::BitArray

BitArray class.

class BitArray

BitArray class.

Represents a dynamic array of bits and provides utilities for manipulating them.

RaeptorCogs::BitArray bitArray;
bitArray.set(5);
bool isSet = bitArray.test(5); // true

Public Functions

BitArray() = default

Default constructor for BitArray.

~BitArray() = default

Destructor for BitArray.

inline BitArray &set(size_t index)

Set the bit at the specified index.

Note

Automatically resizes the underlying storage if the index is out of bounds.

Parameters:

index – The index of the bit to set.

Returns:

Reference to the BitArray for chaining.

inline bool test(size_t index)

Test if the bit at the specified index is set.

Note

Returns false if the index is out of bounds.

Parameters:

index – The index of the bit to test.

Returns:

true if the bit is set, false otherwise.

inline void clear()

Clear all bits in the BitArray.

Note

Resets the BitArray to an empty state.

inline std::vector<uint64_t> data() const

Get the underlying data of the BitArray.

Returns:

Vector of uint64_t representing the bits.

Private Members

std::vector<uint64_t> bits

Underlying storage for the bits.

Each uint64_t represents 64 bits.

Note

Uses a vector to allow dynamic resizing.

Functions

Functions

Function

Description

std::operator<<(std::ostream &os, const RaeptorCogs::BitArray &bitArray)

Stream output operator for BitArray.

inline std::ostream &std::operator<<(std::ostream &os, const RaeptorCogs::BitArray &bitArray)

Stream output operator for BitArray.

Parameters:
  • os – Output stream.

  • bitArray – BitArray instance to output.

Returns:

Reference to the output stream.