struct

Pf::Kit::Sparse32(T)

Inherits Struct / Value / Object

Constants

CAPS = StaticArray(UInt8, 33).new(0_u8)

Maps population count (array size) to capacity directly.

GROWTH = StaticArray(UInt8, 33).new(0_u8)

Maps item count to expected capacity. '0' means 'keep' (do not grow).

Constructors

new(mem : Pointer(T), bitmap : UInt32)
Source

Instance methods

at?(index : Int) : T | Nil

Returns the element at index, or nil.

index must be in 0...32, otherwise this method raises IndexError.

Source
bitmap

Returns the bitmap. The bitmap specifies which slots out of the 32 available ones are occupied.

Source
each(from lo = 0_u8, & : T, UInt8 -> )

Yields each element from this array followed by its index.

  • lo can be used to specify the lower bound (the index where to start; inclusive).
Source
empty?

Returns true if this array contains no elements.

Source
inspect(io)
Source
reverse_each

Yields each element from this array starting at the rightmost one and moving left.

Source
size

Returns the amount of elements in this array.

Source
to_unsafe

Returns a pointer to the internal buffer where self's elements are stored.

Source
with(index : Int, el : T) : Sparse32(T)

Returns a copy of this array where el is present at index.

Source
with!(index : Int, el : T) : self

Modifies this array at index by updating or inserting el there.

Source
without(index : Int) : Sparse32(T)

Returns a copy of this array where the element at index is absent.

Source
without!(index : Int) : self

Modifies this array by removing the element at index if it was present.

Source