struct Pf::Core::Sparse32(T)
- Pf::Core::Sparse32(T)
- Struct
- Value
- Object
Defined in:
permafrost/core/sparse32.crConstant 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
-
#at?(index : Int) : T | Nil
Returns the element at index, or nil.
-
#bitmap : UInt32
Returns the bitmap.
-
#each(from lo = 0_u8, & : T, UInt8 -> )
Yields each element from this array followed by its index.
-
#empty? : Bool
Returns
true
if this array contains no elements. -
#size
Returns the amount of elements in this array.
-
#to_unsafe : Pointer(T)
Returns a pointer to the internal buffer where
self
's elements are stored. -
#with(index : Int, el : T) : Sparse32(T)
Returns a copy of this array where el is present at index.
-
#with!(index : Int, el : T) : self
Modifies this array at index by updating or inserting el there.
-
#without(index : Int) : Sparse32(T)
Returns a copy of this array where the element at index is absent.
-
#without!(index : Int) : self
Modifies this array by removing the element at index if it was present.
Constructor Detail
Instance Method Detail
Returns the element at index, or nil.
index must be in 0...32
, otherwise this method raises IndexError
.
Returns the bitmap. The bitmap specifies which slots out of the 32 available ones are occupied.
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).
Returns a pointer to the internal buffer where self
's elements are stored.
Returns a copy of this array where el is present at index.
Modifies this array at index by updating or inserting el there.
Returns a copy of this array where the element at index is absent.
Modifies this array by removing the element at index if it was present.