aboutsummaryrefslogtreecommitdiff
path: root/core/container
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2022-08-29 09:38:53 +0100
committerGitHub <noreply@github.com>2022-08-29 09:38:53 +0100
commitfc47b5dee04378e151fcf87bf7299f23b27e88ec (patch)
tree3aa4b1deadc9a0067c7c99b287b2105c747bba46 /core/container
parent3d4698debeac92e86da0f2771207e135ce06b223 (diff)
parent6c2e0b09ba04c332f58695db55665fb6f66ddbc3 (diff)
Merge pull request #1987 from colrdavidson/more_queue
Add more queue helpers
Diffstat (limited to 'core/container')
-rw-r--r--core/container/queue/queue.odin7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/container/queue/queue.odin b/core/container/queue/queue.odin
index ae1ca9f62..a42d0e5a4 100644
--- a/core/container/queue/queue.odin
+++ b/core/container/queue/queue.odin
@@ -73,11 +73,18 @@ get :: proc(q: ^$Q/Queue($T), #any_int i: int, loc := #caller_location) -> T {
front :: proc(q: ^$Q/Queue($T)) -> T {
return q.data[q.offset]
}
+front_ptr :: 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]
}
+back_ptr :: 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))