#include "tensorstore/util/small_bit_set.h"
template <size_t N>
class tensorstore::SmallBitSet;

Bit set that fits in a single unsigned integer.

This is similar to std::bitset<N>, but supports iterators, and for simplicity is limited to a single unsigned integer.

Types

type Uint;

N-bit unsigned integer type used to represent the bit set.

using value_type = bool;

Container value type.

using reference = BitRef<Uint>;

Proxy reference type.

type BoolsView;

Mutable view of SmallBitSet bits.

type ConstBoolsView;

Immutable view of SmallBitSet bits.

type IndexView;

Immutable view of SmallBitSet indices.

Constructors

constexpr SmallBitSet();

Constructs an all-zero vector.

constexpr SmallBitSet(T value);

Constructs a vector with all bits set to value.

static constexpr SmallBitSet
FromIndices(const int (&positions)[NumBits]);

Constructs the set containing bits at the specified indices.

static constexpr SmallBitSet UpTo(size_t k);

Constructs the set [0, k).

static constexpr SmallBitSet FromUint(Uint bits);

Constructs from an unsigned integer as a bit vector.

static constexpr SmallBitSet FromBools(const bool (&bits)[NumBits]);

Constructs from an array of bool values.

Methods

static constexpr SmallBitSet FromIndexRange(Range&range);
static constexpr SmallBitSet
FromIndexRange(Iterator beginIterator end);

Constructs the set containing bits at the indices specified by the range.

static constexpr SmallBitSet FromBoolRange(Range&range);
static constexpr SmallBitSet
FromBoolRange(Iterator beginIterator end);

Constructs the set containing bools provided by the range.

constexpr SmallBitSetoperator=(T value);

Sets all bits to the specified value.

static constexpr size_t size();
constexpr size_t count() const;

Returns the static size, N.

constexpr bool none() const;

Returns true if the set is empty.

constexpr bool any() const;

Returns true if the set is not empty.

constexpr bool all() const;

Returns true if all bits are set.

constexpr bool test(int pos) const noexcept;

Returns true if the specified bit is present in the set.

constexpr SmallBitSetset(int pos) noexcept;

Add the specified bit to the set.

constexpr reference operator[](size_t offset);
constexpr bool operator[](size_t offset) const;

Returns a reference to an individual bit.

constexpr Uint to_uint() const;

Returns the contents of the bitset as an unsigned integer.

Conversion operators

explicit operator bool() const;

Returns true if any bit is set.

Set operations

friend constexpr SmallBitSet operator~(SmallBitSet v);

Computes the complement of the set.

friend constexpr SmallBitSet operator&(SmallBitSet aSmallBitSet b);
friend constexpr SmallBitSet&
operator&=(SmallBitSetaSmallBitSet b);

Computes the intersection of two sets.

friend constexpr SmallBitSet operator^(SmallBitSet aSmallBitSet b);
friend constexpr SmallBitSet&
operator^=(SmallBitSetaSmallBitSet b);

Computes the exclusive OR of two sets.

friend constexpr SmallBitSet operator|(SmallBitSet aSmallBitSet b);
friend constexpr SmallBitSet&
operator|=(SmallBitSetaSmallBitSet b);

Computes the union of two sets.

Friend functions

friend constexpr bool operator==(SmallBitSet aSmallBitSet b);
friend constexpr bool operator!=(SmallBitSet aSmallBitSet b);

Compares two sets for equality.

friend std::ostreamoperator<<(std::ostreamosSmallBitSet v);

Prints to an output stream.

class tensorstore::BitRef<T>;

Mutable or constant reference to a single bit of a packed bit sequence.

class tensorstore::BitIterator<T>;

Iterator within a packed bit sequence.