Created
September 28, 2022 12:55
-
-
Save tauraamui/f7a12565ee3ee16a8cb6c509b468243d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Internal growinh procedure | |
_grow :: proc(q: ^$Q/Queue($T), min_capacity: uint = 0) -> bool { | |
new_capacity := max(min_capacity, uint(8), uint(builtin.len(q.data))*2) | |
n := uint(builtin.len(q.data)) | |
builtin.resize(&q.data, int(new_capacity)) or_return | |
if q.offset + q.len > n { | |
diff := n - q.offset | |
copy(q.data[new_capacity-diff:], q.data[q.offset:][:diff]) | |
q.offset += new_capacity - n | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment