SectrPrototype/code/girme_stack.odin
Ed_ 4deee942a8 General codebase refactor & cleanup
Renamed HashTable to HMapZPL, with procs having the zpl_ namespace prefix.
(I want to eventually get away from using it)

Started to use the grime pattern for library aliasing better.
2024-02-27 07:50:57 -05:00

27 lines
553 B
Odin

package sectr
Stack :: struct ( $ Type : typeid, $ Size : i32 ) {
idx : i32,
items : [ Size ] Type,
}
stack_push :: proc( using stack : ^ Stack( $ Type, $ Size ), value : Type ) {
verify( idx < len( items ), "Attempted to push on a full stack" )
items[ idx ] = value
idx += 1
}
stack_pop :: proc( using stack : ^ Stack( $ Type, $ Size ) ) {
verify( idx > 0, "Attempted to pop an empty stack" )
idx -= 1
if idx == 0 {
items[idx] = {}
}
}
stack_peek :: proc( using stack : ^ Stack( $ Type, $ Size ) ) -> ^ Type {
return & items[idx]
}