package dolmen
A parser library for automated deduction
Install
Dune Dependency
Authors
Maintainers
Sources
dolmen-0.8.1.tbz
sha256=80fc33ae81817a79c6e6b2f6c01c4cfcc0af02bfe4d2d1b87cf70b84cdde3928
sha512=3a44a99bce871161bc70cf909c813e9e6c91c590873cbc163c69b2ec90ab5be65bf0bf45430bc8d00d85d75cf0af004b06b8f5f1c9d4d47c8a30ab9f28762c04
doc/src/dolmen.std/vec.ml.html
Source file vec.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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
(* This file is free software, part of dolmen. See file "LICENSE" for more information *) (* Modules and aliases *) (* ************************************************************************* *) type 'a t = { mutable data : 'a array; mutable sz : int; } let make n x = { data = Array.make n x; sz = 0 } let[@inline] create () = { data = [||]; sz = 0} let[@inline] clear s = s.data <- [||]; s.sz <- 0 let[@inline] shrink t i = assert (i >= 0); assert (i<=t.sz); t.sz <- i let[@inline] pop t = if t.sz = 0 then invalid_arg "vec.pop"; let x = Array.unsafe_get t.data (t.sz - 1) in t.sz <- t.sz - 1; x let[@inline] size t = t.sz let[@inline] is_empty t = t.sz = 0 let[@inline] is_full t = Array.length t.data = t.sz let[@inline] copy t : _ t = let data = Array.copy t.data in {t with data} (* grow the array *) let[@inline never] grow_to_double_size t x : unit = if Array.length t.data = Sys.max_array_length then ( failwith "vec: cannot resize"; ); let size = min Sys.max_array_length (max 4 (2 * Array.length t.data)) in let arr' = Array.make size x in Array.blit t.data 0 arr' 0 (Array.length t.data); t.data <- arr'; assert (Array.length t.data > t.sz); () let[@inline] get t i = if i < 0 || i >= t.sz then invalid_arg "vec.get"; Array.unsafe_get t.data i let[@inline] last t = if t.sz = 0 then invalid_arg "vec.last"; Array.unsafe_get t.data (t.sz - 1) let[@inline] push t x : unit = if is_full t then grow_to_double_size t x; Array.unsafe_set t.data t.sz x; t.sz <- t.sz + 1 let[@inline] set t i v = if i < 0 || i > t.sz then invalid_arg "vec.set"; if i = t.sz then ( push t v ) else ( Array.unsafe_set t.data i v )
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>