Data.Map, Data.Set working together

Adrian Hey ahey at iee.org
Thu Apr 7 09:08:45 EDT 2005


On Thursday 07 Apr 2005 4:19 am, Ketil Malde wrote:
> I need to search intervals -- i.e. I'd like to store integer keys, and
> looking up any integer should return the largest key less than my
> query.  (Ideally with it's associated datum, but that could of course
> be stored in a separate map).
>
> Do any of the set/map implementations support this?

The Zipper for the AVL library supports this. Unfortunately
I haven't published the code yet :-(. The relevant function
is:

-- | Attempts to open a sorted AVL tree at the greatest element which
-- is less than or equal to some value, according to the supplied comparison.
tryOpenByLE :: (a -> b -> Ordering) -> a -> AVL b -> Maybe (ZAVL b)

You can then step left or right through the tree (inspecting 
modifying/inserting/deleting elements as you require).

Regards
--
Adrian Hey




More information about the Libraries mailing list