A Generic Stack from Scratch
Type-parametric LIFO over an allocator.
What a Stack Does
A stack is a LIFO collection: the last item you push is the first one you pop. Think of plates piled on a counter. 🍽️
Make It Generic
To hold any element type, write a function that takes a type and returns a struct type. Each call gives a stack tailored to that type.
fn Stack(comptime T: type) type {
return struct {};
}All lessons in this course
- A Generic Stack from Scratch
- A Singly Linked List
- Using HashMap and AutoHashMap
- Profiling and Safety Trade-offs