0 | ||| Linear RRB Vector Internals
15 | %hide Data.Vect.Quantifiers.All.get
16 | %language ElabReflection
18 | --------------------------------------------------------------------------------
19 | -- Internal Utility
20 | --------------------------------------------------------------------------------
22 | ||| Convenience interface for bitSize that doesn't use an implicit parameter.
23 | private
29 | --------------------------------------------------------------------------------
30 | -- Internals
31 | --------------------------------------------------------------------------------
37 | ||| The number of bits used per level.
38 | export
42 | ||| The maximum size of a block.
43 | export
47 | ||| The mask used to extract the index into the array.
48 | export
52 | export
57 | export
62 | export
68 | export
79 | i
85 | idx''
88 | where
95 | assert_total $ idris_crash "Data.RRBVector1.Internal.relaxedRadixIndex.loop: index out of bounds"
100 | idx
104 | --------------------------------------------------------------------------------
105 | -- Internal Tree Representation
106 | --------------------------------------------------------------------------------
108 | ||| A linear internal tree representation.
112 | Unbalanced : {usize : Nat} -> (usize ** MArray s usize (Tree1 s a)) -> IArray usize Nat -> Tree1 s a
115 | --------------------------------------------------------------------------------
116 | -- Tree Utilities
117 | --------------------------------------------------------------------------------
119 | export
125 | export
131 | export
142 | export
150 | arr
152 | export
156 | True
158 | False
160 | True
162 | ||| Computes the size of a tree with shift.
163 | export
169 | where
193 | t
195 | ||| Turns an array into a tree node by computing the sizes of its subtrees.
196 | ||| sh is the shift of the resulting tree.
197 | export
210 | where
216 | where
229 | (assert_total $ idris_crash "Data.RRBVector.Internal.computeSizes.createArrNat.go: can't convert Nat to Fin") # t
243 | where
251 | (assert_total $ idris_crash "Data.RRBVector.Internal.computeSizes.isBalanced: can't convert Nat to Fin") # t
262 | export
267 | where
274 | i
278 | assert_total $ idris_crash "Data.RRBVector1.Internal.countTrailingZeros: can't convert Nat to Fin"
282 | i
286 | ||| Nat log base 2.
287 | export
293 | where
297 | where
304 | i
312 | i
316 | --------------------------------------------------------------------------------
317 | -- Linear RRB Vectors
318 | --------------------------------------------------------------------------------
320 | ||| A linear relaxed radix balanced vector (RRBVector1).
321 | ||| It supports fast indexing, iteration, concatenation and splitting.