summaryrefslogtreecommitdiff
path: root/std/stack.zc
diff options
context:
space:
mode:
authorLam Wei Lun <weilun.lam@gmail.com>2026-01-21 19:35:12 +0800
committerLam Wei Lun <weilun.lam@gmail.com>2026-01-21 19:35:12 +0800
commite8ef3454880b92a5485a339b3b6fe7b64cfe5305 (patch)
tree7e82fc6cb9ef2f81919a383ff83c6b79acd6a764 /std/stack.zc
parent8144aef45d5db22ab2895b41448cd76bf01e05cc (diff)
Add length, clear, is_empty to Stack and Queue
Diffstat (limited to 'std/stack.zc')
-rw-r--r--std/stack.zc12
1 files changed, 12 insertions, 0 deletions
diff --git a/std/stack.zc b/std/stack.zc
index 3d7c3c5..7df77f1 100644
--- a/std/stack.zc
+++ b/std/stack.zc
@@ -50,6 +50,18 @@ impl Stack<T> {
}
return Option<T>::None();
}
+
+ fn length(self) -> usize {
+ return self.len;
+ }
+
+ fn clear(self) {
+ self.len = 0;
+ }
+
+ fn is_empty(self) -> bool {
+ return self.len == 0;
+ }
}
impl Drop for Stack<T> {