mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
container/queue: Deprecate peek_*
The `*_ptr` and `peek_*` procedures did the same thing, except `peek_*` was over-cautiously putting the index through a modulo when all assignments to `q.offset` are already wrapped.
This commit is contained in:
@@ -127,16 +127,14 @@ get_ptr :: proc(q: ^$Q/Queue($T), #any_int i: int, loc := #caller_location) -> ^
|
|||||||
return &q.data[idx]
|
return &q.data[idx]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@(deprecated="Use `front_ptr` instead")
|
||||||
peek_front :: proc(q: ^$Q/Queue($T), loc := #caller_location) -> ^T {
|
peek_front :: proc(q: ^$Q/Queue($T), loc := #caller_location) -> ^T {
|
||||||
runtime.bounds_check_error_loc(loc, 0, builtin.len(q.data))
|
return front_ptr(q, loc)
|
||||||
idx := q.offset%builtin.len(q.data)
|
|
||||||
return &q.data[idx]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@(deprecated="Use `back_ptr` instead")
|
||||||
peek_back :: proc(q: ^$Q/Queue($T), loc := #caller_location) -> ^T {
|
peek_back :: proc(q: ^$Q/Queue($T), loc := #caller_location) -> ^T {
|
||||||
runtime.bounds_check_error_loc(loc, int(q.len - 1), builtin.len(q.data))
|
return back_ptr(q, loc)
|
||||||
idx := (uint(q.len - 1)+q.offset)%builtin.len(q.data)
|
|
||||||
return &q.data[idx]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push an element to the back of the queue
|
// Push an element to the back of the queue
|
||||||
|
|||||||
Reference in New Issue
Block a user