struct Lapis::Core::ArenaBuffer(T)

Overview

Stack-allocated, zero-GC appendable typed buffer view backed by a Slice(T) carved out of a FrameArena. Ideal for building per-frame vertex, color, and line batches in sol-vin/diorite or signal argument scratch arrays.

Defined in:

lapis/core/frame_arena.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class Object

try?(&)
try?
try?

Constructor Detail

def self.new(raw_slice : Slice(T), size : Int32 = 0) #

Class Method Detail

def self.from_slice(slice : Slice(T), size : Int32 = 0) : ArenaBuffer(T) #

Instance Method Detail

def <<(value : T) : self #

Fluent append operator (buf << item).


def [](index : Int32) : T #

def []=(index : Int32, value : T) : T #

def []?(index : Int32) : T | Nil #

def capacity : Int32 #

def clear : self #

Resets the logical element count to 0 while retaining the underlying slice capacity.


def each(& : T -> ) : Nil #

def empty? : Bool #

def full? : Bool #

def push(value : T) : Bool #

Appends a single element to the arena buffer if space remains. Returns true if written, false if capacity was reached.


def push_line(a : T, b : T) : Bool #

Appends a pair of elements (e.g. start/end vertices for a 2D/3D line segment) atomically if at least 2 slots remain.


def raw_slice : Slice(T) #

def remaining : Int32 #

def size : Int32 #

def to_slice : Slice(T) #

Returns a zero-allocation Slice(T) view over the written elements (0...@size).


def to_unsafe : Pointer(T) #

def unsafe_fetch(index : Int32) : T #