package b0
Software construction and deployment kit
Install
dune-project
Dependency
Authors
Maintainers
Sources
b0-0.0.6.tbz
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0
doc/src/b0.memo/b0_random_queue.ml.html
Source file b0_random_queue.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
(*--------------------------------------------------------------------------- Copyright (c) 2025 The b0 programmers. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) type 'a t = { rand : Random.State.t; mutable length : int; mutable slots : 'a option array } let grow q = let slots' = Array.make (2 * q.length) None in Array.blit q.slots 0 slots' 0 q.length; q.slots <- slots' let empty ?(rand = Random.State.make_self_init ()) () = { rand; length = 0; slots = Array.make 256 None } let add q v = if q.length = Array.length q.slots then grow q; q.slots.(q.length) <- Some v; q.length <- q.length + 1; () let take q = match q.length with | 0 -> None | _ -> let i = Random.State.int q.rand q.length in let v = q.slots.(i) in let last = q.length - 1 in q.slots.(i) <- q.slots.(last); q.slots.(last) <- None; q.length <- last; v let length q = q.length
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>