roxen.lists.pike.general

Subject Author Date
Re: Arrays, multisets, mappings: avoiding unnecessary memory (re)assigns Martin Stjernholm <mast[at]lysator[dot]liu[dot]se> 08-09-2009
Martin Bähr <<mbaehr[at]email.archlab.tuwien.ac.at>> wrote:

> what is the reason for this difference?

Historical, I think. Once upon a time multisets were implemented as
sorted arrays.

> would it it be possible to implement multisets as mapping(mixed:int) or
> is there a specific quality of multisets that prevents this?

Not really, although handling duplicate indices would require a bit of
tweaking in a hash table implementation. But there would be little use
to have hash tables in two forms. If you want a hash table, use a
mapping.

Rather, the intention is at some point to extend multisets to be able
to take values, just like mappings, and to take a custom sort
function, so that their binary tree structure is fully usable from the
pike level. Most low-level support for that is already in place.