<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Chris King" <colanderman@gmail.com><br><div><br></div>
<style>body { font-family:'DejaVu Sans Mono'; font-size:12px}</style>
<div>On Wed, 30 Oct 2013 08:40:44 -0400, Robert Virding <robert.virding@erlang-solutions.com> wrote:<br></div><br><blockquote style="margin: 0 0 0.80ex; border-left: #0000FF 2px solid; padding-left: 1ex"><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>- I need functions:<br></div><div><br></div><div>first(Map) -> {Key,Value} | error.<br></div><div>last(Map) -> {Key,Value} | error.</div><div>next(Key, Map) -> {Key1,Value} | error.<br></div><div>prev(Key, Map) -> {Key1,Value} | error.<br></div><div><br></div><div>for stepping through maps. Have them return both key and value in one go as it saves an explicit fetch and the extra cost is minimal.</div></div></blockquote><div><br></div><div><div>I don't get this use case. Why do you need syntax support for a key-value map where you don't know a priori what the keys and values are? Why don't dict() and friends suffice?<br></div><div><br></div><div>To me this is akin to iterating through a record/tuple.</div></div></blockquote><div>I need this ability to step through a map/dict/whatever in an application I am working on (luerl). Dict does not provide this type of functionality. It would be easy to hack into an orddict but I don't want to use lists. Gb_trees provides an iterators but they are quite limited in that they only allow you to step through the whole tree from beginning to end; you can't jump in in the middle. Which I need to be able to do.<br></div><div><br></div><div>I solved this by writing my own dict compatible module, ttdict, based on 2-3 trees where I added these 4 extra functions. Ttdict was quite good and provided dict API on ordered keys which is faster than gb_trees. I had planned to add it to the libraries but with maps the need for it has more or less disappeared. I think.<br></div><div><br></div><div>My idea was that now maps are coming I could replace ttdict with maps, not for functionality but for speed. Hence the request for the extra functions. I am assuming that doing it in C will be faster than doing it in Erlang.<br></div><div><br></div><div>What would be interesting to see is how much faster you could get a dict replacement which uses hashing and doesn't give key ordering.<br></div><div><br></div><div>Robert<br></div><div><br></div></div></body></html>