## miden::core::collections::sorted_array
| Procedure | Description |
| ----------- | ------------- |
| find_word | Finds a value in a sorted array of words.<br /><br />**The input array must be sorted in non-decreasing lexicographic order.** The host event handler validates this and will return an error if the array is not sorted.<br /><br />Input: [VALUE, start_ptr, end_ptr]<br />Output: [is_value_found, value_ptr, start_ptr, end_ptr]<br /><br /># Panics<br /><br />Panics if:<br />- start_ptr, end_ptr are not word-aligned<br />- `start_ptr > end_ptr`<br /><br />Cycles:<br />Value exists: 46 cycles<br />Value doesn't exist and the array is empty: 25 cycles<br />Value doesn't exist and is smaller than all elements: 151 cycles<br />Value doesn't exist and is larger than all elements: 149 cycles<br />Value doesn't exist: 286 cycles<br /> |
| find_key_value | Finds a key in a sorted array of (key, value) word tuples.<br /><br />**The keys in the array must be sorted in non-decreasing lexicographic order.** The host event handler validates this and will return an error if the keys are not sorted.<br /><br />Inputs: [KEY, start_ptr, end_ptr]<br />Outputs: [is_key_found, key_ptr, start_ptr, end_ptr]<br /><br /># Panics<br /><br />Panics if:<br />- start_ptr is not word-aligned<br />- end_ptr is not double-word-aligned with the start_ptr:<br />- `(end_ptr - start_ptr)` must be divisible by 8<br />- `start_ptr > end_ptr`<br /> |
| find_half_key_value | Finds a half-key in a sorted array of (key, value) word tuples.<br /><br />Half-key means that, out of the keys in the array, only half of the key - the most significant<br />element (prefix) and the second most significant element (suffix) - need to match.<br /><br />**The half-keys in the array must be sorted in non-decreasing lexicographic order.** The host event handler validates this and will return an error if the half-keys are not sorted.<br /><br />Inputs: [key_suffix, key_prefix, start_ptr, end_ptr]<br />Output: [is_key_found, key_ptr, start_ptr, end_ptr]<br /><br /># Panics<br /><br />Panics if:<br />- start_ptr is not word-aligned<br />- end_ptr is not double-word-aligned with the start_ptr:<br />- `(end_ptr - start_ptr)` must be divisible by 8<br />- `start_ptr > end_ptr`<br /> |