summaryrefslogtreecommitdiff
path: root/docs/std/stack.md
diff options
context:
space:
mode:
authorZuhaitz <zuhaitz.zechhub@gmail.com>2026-01-31 17:22:17 +0000
committerGitHub <noreply@github.com>2026-01-31 17:22:17 +0000
commit962d659c61212b1a23acfe56dda7cb92b721feda (patch)
treeba1637d3885213095b312f81a477c33b1ebca6aa /docs/std/stack.md
parente521ee7d175393ef37579ebd61ccb7e8d56a397f (diff)
parent91ed9fdd65e09bd6cd32e44dd07c390f2cf79c22 (diff)
Merge branch 'main' into main
Diffstat (limited to 'docs/std/stack.md')
-rw-r--r--docs/std/stack.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/docs/std/stack.md b/docs/std/stack.md
new file mode 100644
index 0000000..6e5da84
--- /dev/null
+++ b/docs/std/stack.md
@@ -0,0 +1,38 @@
+# Stack (`std/stack.zc`)
+
+The `std/stack` module provides a LIFO (Last-In, First-Out) stack data structure.
+
+## Usage
+
+```zc
+import "std/stack.zc"
+```
+
+## Types
+
+### Struct `Stack<T>`
+
+A generic stack.
+
+#### Methods
+
+- **`fn new() -> Stack<T>`**
+ Creates a new empty stack.
+
+- **`fn push(self, value: T)`**
+ Pushes a value onto the top of the stack.
+
+- **`fn pop(self) -> Option<T>`**
+ Removes and returns the top element of the stack. Returns `None` if empty.
+
+- **`fn length(self) -> usize`**
+ Returns the number of elements in the stack.
+
+- **`fn is_empty(self) -> bool`**
+ Returns `true` if the stack contains no elements.
+
+- **`fn clear(self)`**
+ Removes all elements from the stack.
+
+- **`fn clone(self) -> Stack<T>`**
+ Creates a deep copy of the stack.