Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe HaskellNone

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 #