mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
math/rand: choice_bit_set return not_empty -> ok
This commit is contained in:
@@ -695,8 +695,8 @@ Inputs:
|
|||||||
- set: The `bit_set` to choose a random set bit from
|
- set: The `bit_set` to choose a random set bit from
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
- res: The randomly selected bit, or the zero value if `not_empty` is `false`
|
- res: The randomly selected bit, or the zero value if `ok` is `false`
|
||||||
- not_empty: Whether the bit_set was not empty and thus `res` is actually a random set bit
|
- ok: Whether the bit_set was not empty and thus `res` is actually a random set bit
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
import "core:math/rand"
|
import "core:math/rand"
|
||||||
@@ -722,7 +722,7 @@ Possible Output:
|
|||||||
5 true
|
5 true
|
||||||
*/
|
*/
|
||||||
@(require_results)
|
@(require_results)
|
||||||
choice_bit_set :: proc(set: $T/bit_set[$E], gen := context.random_generator) -> (res: E, not_empty: bool) {
|
choice_bit_set :: proc(set: $T/bit_set[$E], gen := context.random_generator) -> (res: E, ok: bool) {
|
||||||
total_set := card(set)
|
total_set := card(set)
|
||||||
if total_set == 0 {
|
if total_set == 0 {
|
||||||
return {}, false
|
return {}, false
|
||||||
|
|||||||
Reference in New Issue
Block a user