Multi-associative array
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Feb 23 17:05:04 PST 2014
On 2/22/14, 11:10 PM, Etienne Cimon wrote:
> On 2014-02-23 01:27, H. S. Teoh wrote:
>> You can just use a struct or tuple as the AA key to achieve the same
>> thing.
>
> I thought of that but it's not immediately obvious how I could achieve
> sorting or filtering by a certain field
>
> e.g.
> auto sorted = aa.sort!(Key.y => { a < b })
> auto filtered = aa.filter! ....
>
> foreach(x, y, z ; aa){
> ....
> }
>
> I don't see a very simple way of doing this right now. I'm sure someone
> thought of a library for this?
The way multiple binary tree (or rb-tree) indexes are achieved is by
storing multiple pointers with the same value. That way really multiple
threes are threaded using the same value nodes.
There's no trivial way to do this. It would be very valuable to
generalize RBTree to accept multiple predicates and build such multiple
indexes.
Andrei
More information about the Digitalmars-d
mailing list