From 6c2e0b09ba04c332f58695db55665fb6f66ddbc3 Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Mon, 29 Aug 2022 00:43:35 -0700 Subject: [PATCH] Add more queue helpers --- core/container/queue/queue.odin | 7 +++++++ 1 file changed, 7 insertions(+) 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))