<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>I only wanted to mention that maps is not the only key-value data
structure available in Erlang and may not the best one to
implement such an iterator. I once did a benchmark of available
key-value data stores measuring not only the speed, but also the
amount of consumed memory:</p>
<p><a href="https://gist.github.com/amiramix/d43c9a73a6fe6d651d7f">https://gist.github.com/amiramix/d43c9a73a6fe6d651d7f</a></p>
<p>Maps are quite performant but process dictionary is still quicker
and maps are the worst when it comes to consumed memory, taking
twice as much as dict or process dictionary and over 5 times as
much memory as ets.</p>
<p>BTW if you have a look and find any issues please let me know and
I will be happy to correct and rerun. The test simply initializes
the data structure with InitSize amount of Key-Value elements, and
then starts measuring the time and memory needed to write/read
Accesses amount of Key-Value/Key elements with randomly generated
Keys.<br>
</p>
<p>Greg<br>
</p>
<br>
<div class="moz-cite-prefix">On 09/05/2016 16:29, Robert Virding
wrote:<br>
</div>
<blockquote
cite="mid:CAH_GQaN=HU7rHfJyw9BQrcn7cL6ig7Sev-x5LtugGecvNy4zyg@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>OK, I am the one who asked for first/next so this is my
use case.<br>
<br>
</div>
As Lukas mentioned I need this to implement Lua tables in
Erlang using maps.<br>
<br>
I need to be able to iterate over a map one key/value pair at
a time. For me the order is completely irrelevant as along as
if I do a sequence of first-next-next-... using the previous
key in the next next I am guaranteed to *uniquely* get *all*
the keys in the map. If I modify the map and try to continue
from where I was then all bets are of and there are no
guarantees any more that I will get all keys or that they will
be unique.<br>
<br>
Lua has exactly this interface to its tables so I need to be
able to do it as well. Not having it is not an option. So
while having maps or folds over a map is great there is no way
these can be used to implement what I need efficiently. That's
it.<br>
<br>
</div>
<div>Now I use a private 2-3 trees implementation of dict with
the added functions and it works well. But using maps would
seem logical and more efficient.<br>
<br>
</div>
<div>That's about it.<br>
<br>
</div>
<div>Robert<br>
<br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 9 May 2016 at 16:54, Fred Hebert <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:mononcqc@ferd.ca" target="_blank">mononcqc@ferd.ca</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">On 05/09,
zxq9 wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex"><span
class="">
On Monday 09 May 2016 15:22:17 Lukas Larsson wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
On Mon, May 9, 2016 at 2:54 PM, zxq9 <<a
moz-do-not-send="true" href="mailto:zxq9@zxq9.com"
target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:zxq9@zxq9.com">zxq9@zxq9.com</a></a>> wrote:<br>
<br>
><br>
> That's my whole point. Why the desire for a
next/1 and previous/1<br>
> instead of a list-style operation over the map as
a whole, since<br>
> outside of an abstract sense of "doing something
with each element"<br>
> there is nothing interesting that can possibly be
gained from<br>
> introducing an implicit concept of order?<br>
><br>
</blockquote>
<br>
</span><span class="">
Sure, internally I imagine there are a million super
slick ways to use this,<br>
and I lack the imagination to see what they may be.<br>
<br>
</span></blockquote>
<br>
- partial iteration to look for an element<br>
- partial iteration to only modify a subrange of the whole
map; for example, re-hashing a window of N components. If
your map has 10 million items and you want to re-hash 25 of
them, then going over the whole map every time is going to
eat you up on the computation (this one is more useful with
a total stable order defined)<br>
- implementing your own map/fold/filter combination as a
single pass<br>
without needing to iterate and convert the whole map at
once<br>
- ability to do lookahead/look-behind in an iteration to
arbitrary levels without implementing your own ad-hoc
zipper or buffering all of the content you have seen<br>
<br>
Those are a few I have in mind can be doable that way --
I've mostly seen them at work or wanted them for ETS tables,
but I'm sure someone could twist a map into having the same
requirements.
<div class="HOEnZb">
<div class="h5"><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a moz-do-not-send="true"
href="mailto:erlang-questions@erlang.org"
target="_blank">erlang-questions@erlang.org</a><br>
<a moz-do-not-send="true"
href="http://erlang.org/mailman/listinfo/erlang-questions"
rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</body>
</html>