mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
Merge pull request #1987 from colrdavidson/more_queue
Add more queue helpers
This commit is contained in:
@@ -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 {
|
front :: proc(q: ^$Q/Queue($T)) -> T {
|
||||||
return q.data[q.offset]
|
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 {
|
back :: proc(q: ^$Q/Queue($T)) -> T {
|
||||||
idx := (q.offset+uint(q.len))%builtin.len(q.data)
|
idx := (q.offset+uint(q.len))%builtin.len(q.data)
|
||||||
return q.data[idx]
|
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) {
|
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))
|
runtime.bounds_check_error_loc(loc, i, builtin.len(q.data))
|
||||||
|
|||||||
Reference in New Issue
Block a user