aboutsummaryrefslogtreecommitdiff
path: root/core/container/queue/queue.odin
diff options
context:
space:
mode:
authorJungerBoyo <74600205+JungerBoyo@users.noreply.github.com>2022-06-04 00:12:34 +0200
committerGitHub <noreply@github.com>2022-06-04 00:12:34 +0200
commit78e6cd0c60f22ff42935b92018a13ccda5d192b0 (patch)
tree1d7329c0b41197b2e1579b273c6abe93c253c451 /core/container/queue/queue.odin
parentfb49841b1d8e84cb721f5f73200d4c8158cbb4fa (diff)
front() and back()
based on pop_front(), pop_back()
Diffstat (limited to 'core/container/queue/queue.odin')
-rw-r--r--core/container/queue/queue.odin10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/container/queue/queue.odin b/core/container/queue/queue.odin
index 8ca3a85ac..ae1ca9f62 100644
--- a/core/container/queue/queue.odin
+++ b/core/container/queue/queue.odin
@@ -69,6 +69,16 @@ get :: proc(q: ^$Q/Queue($T), #any_int i: int, loc := #caller_location) -> T {
idx := (uint(i)+q.offset)%builtin.len(q.data)
return q.data[idx]
}
+
+front :: proc(q: ^$Q/Queue($T)) -> T {
+ return q.data[q.offset]
+}
+
+back :: proc(q: ^$Q/Queue($T)) -> T {
+ idx := (q.offset+uint(q.len))%builtin.len(q.data)
+ return q.data[idx]
+}
+
set :: proc(q: ^$Q/Queue($T), #any_int i: int, val: T, loc := #caller_location) {
runtime.bounds_check_error_loc(loc, i, builtin.len(q.data))