struct Pf::Core::Sparse32(T)

Defined in:

permafrost/core/sparse32.cr

Constant Summary

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

Instance Method Summary

Constructor Detail

def self.new(mem : Pointer(T), bitmap : UInt32) #

[View source]
def self.new #

[View source]

Instance Method Detail

def at?(index : Int) : T | Nil #

Returns the element at index, or nil.

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


[View source]
def bitmap : UInt32 #

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


[View source]
def 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).

[View source]
def empty? : Bool #

Returns true if this array contains no elements.


[View source]
def size #

Returns the amount of elements in this array.


[View source]
def to_unsafe : Pointer(T) #

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


[View source]
def with(index : Int, el : T) : Sparse32(T) #

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


[View source]
def with!(index : Int, el : T) : self #

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


[View source]
def without(index : Int) : Sparse32(T) #

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


[View source]
def without!(index : Int) : self #

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


[View source]