template <uint32_t max_count>

class IntSet

Defined at line 30 of file ../../zircon/kernel/lib/fbl/include/fbl/int_set.h

IntSet is a bitmap-based set of integers. The main differences with other implementations

is that is meant to be very compact. One would expect it to be a wrapper around std::bitset

but the interface of bitset does not allow to efficiently query the bits in the way that the

compiler could always replace loops for ctz or similar intrinsics.

This template takes |max_count| which is the maximum number of elements it can contain

which does not have to be a power-of-two. The elements are from 0 to max_count - 1, thus

these elements are called index or indexes in the interface.

Public Members

static const size_t kFixedOverhead

Public Methods

zx::result<uint32_t> allocate_new ()

adds and returns the first integer not in the set or errors out if the set is full.

Defined at line 36 of file ../../zircon/kernel/lib/fbl/include/fbl/int_set.h

template <typename Fn>
size_t remove_all_fn (Fn fn)

Removes all integers in the set, for each |fn| is called with the id being removed.

Defined at line 61 of file ../../zircon/kernel/lib/fbl/include/fbl/int_set.h

bool add (uint32_t index)

Adds a new |index| or does nothing if already set.

Defined at line 78 of file ../../zircon/kernel/lib/fbl/include/fbl/int_set.h

bool exists (uint32_t index)

returns true if |index| is in the set.

Defined at line 87 of file ../../zircon/kernel/lib/fbl/include/fbl/int_set.h

bool remove (uint32_t index)

Removes |index| from the set. Returns false if |index| was not in the set.

Defined at line 96 of file ../../zircon/kernel/lib/fbl/include/fbl/int_set.h

uint32_t free_count ()

Returns how many free slots there are.

Defined at line 105 of file ../../zircon/kernel/lib/fbl/include/fbl/int_set.h