summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/queue.zc14
-rw-r--r--std/stack.zc12
2 files changed, 24 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> {
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> {