summaryrefslogtreecommitdiff
path: root/std/queue.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/queue.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/queue.zc')
-rw-r--r--std/queue.zc14
1 files changed, 12 insertions, 2 deletions
diff --git a/std/queue.zc b/std/queue.zc
index 2bbcfaa..31e5dbd 100644
--- a/std/queue.zc
+++ b/std/queue.zc
@@ -38,8 +38,6 @@ impl Queue<T> {
self.cap = self.cap * 2;
self.data = realloc(self.data, sizeof(T) * self.cap);
}
-
- // Assigns it at the back of
self.data[self.len] = value;
self.len = self.len + 1;
}
@@ -56,6 +54,18 @@ impl Queue<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 Queue<T> {