No way to retrieve the base of a Set or Map in O(1)

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Thu Jun 18 11:00:27 UTC 2015


On 18 June 2015 at 20:27, André van Delden
<andre.van.delden at uni-bremen.de> wrote:
> Hello,
>
> there seems to be no way to retrieve the base of a Set or Map in O(1),
> since there is no relevant function in the respective libraries and the
> constructors Bin and Tip are not exported in any module.
> I think retrieving any one element from a Set or Map might be useful
> sometimes, so I modestly ask for an implementation.

For Set there's minView and maxView.

For Map there's both {min,max}View (which returns only the value) and
also {min,max}ViewWithKey which also returns the key.

These are admittedly all O(log n) though.

I suppose the reason for there being no way to obtain the root value
is that it would be both implementation and creation (as in how the
Set/Map was created, due to there being no balancing IIRC) dependent,
and thus difficult to use in any reliable/reproducible fashion.

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


More information about the Libraries mailing list