This conversation should probably move to personal email or the github
issue tracker. This isn't a bug, it's by design. If it didn't work this
way you'd never be able to replace a key that already existed in a map.
John
On 21/11/13 07:56, jean-marc Mercier wrote:
@John
Hello.
I started modifying your RB tree. I noticed that, while inserting two
time the same keys, the last inserted value replace
the previous one into your rbtree. As an illustration the following query
let $map := map:new(
(map:entry("dummy","rocks"),map:entry("dummy","roll")) )
return map:get($map,"dummy")
returns "roll"
I was expecting to "rocks". First : can you reproduce it ? (I modified
your files, and use BaseX interpretor. It is better to check with
another implementation).
Second, should I "roll" your rbtree or is this expected (is this a bug
or not ?) ?
2013/11/20 jean-marc Mercier <jeanmarc.merc...@gmail.com
<mailto:jeanmarc.merc...@gmail.com>>
Yes you're right, using fold should be strightfroward.
For the remove function, I'll try. Hopefully I won't spent too much
time :)
I'll keep you posted
2013/11/20 John Snelson <john.snel...@marklogic.com
<mailto:john.snel...@marklogic.com>>
On 20/11/13 13:16, jean-marc Mercier wrote:
ok. I've done a first draft that is working. I will keep the
code a
little bit to tune and complete it. For instance, that could
be an idea
to implement the remove($map,$key) function, or to implement
key($map).
Implenting keys($map) can be done using the fold() function. I
recall the remove() algorithm being a fair amount harder to
implement in a functional red/black tree, and I didn't need it
so I didn't tackle it.
However, I have to modify your rbtree to do it.
Very happy to accept contributions of a remove() implementation
if you do it. :-)
John
--
John Snelson, Lead Engineer http://twitter.com/jpcs
MarkLogic Corporation http://www.marklogic.com
--
John Snelson, Lead Engineer http://twitter.com/jpcs
MarkLogic Corporation http://www.marklogic.com
_______________________________________________
talk@x-query.com
http://x-query.com/mailman/listinfo/talk