summaryrefslogtreecommitdiff
path: root/std/stack.zc
diff options
context:
space:
mode:
authorZuhaitz <zuhaitz.zechhub@gmail.com>2026-01-21 19:12:32 +0000
committerGitHub <noreply@github.com>2026-01-21 19:12:32 +0000
commit9e47e8e2d7c7c589c3c158cd5ef3069289709fa8 (patch)
tree5061720c3451dd1561ba99ac79c78f487cf4de0c /std/stack.zc
parent83cf9acfa64b9303064db569c662df5806b464aa (diff)
parente8ef3454880b92a5485a339b3b6fe7b64cfe5305 (diff)
Merge pull request #85 from lamweilun/dev/weilun/update_stack_and_queue
Add length, clear and is_empty methods 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> {