Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Util.Array

Contents

Description

Array utilities.

IArray is awkward and I don't like it. vector is nicer but it's a big library so I don't want to depend on it unless I have more than one data structure using arrays.

Synopsis

Documentation

from_list :: [a] -> Array a Source #

at :: String -> Array a -> Int -> a Source #

Like IArray.!, except throw a more informative error, with msg prepended.

in_bounds :: Int -> Array a -> Bool Source #

Is the given index within the array's bounds?

check :: Int -> Array a -> Maybe (Array a) Source #

Just the array if the index is in bounds.

searching

bsearch :: Ord k => Array k -> k -> Int Source #

Find the index of the first element >= the given element in the sorted array.

bsearch_on :: Ord k => (a -> k) -> Array a -> k -> Int Source #

bsearch_with :: (k -> a -> Bool) -> Array a -> k -> Int Source #

_do_bsearch :: (a -> Bool) -> Array a -> Int -> Int -> Int Source #