<div dir="ltr">Fair enough..<div><br></div><div>But if size is a concern, shouldn't we look at a different data structure, like gb_trees/ets?</div><div><br></div><div>Theepan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 30, 2015 at 4:36 AM, Robert Virding <span dir="ltr"><<a href="mailto:rvirding@gmail.com" target="_blank">rvirding@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>Seeing we are wishing here I would like a function which when you call it with a key returns the next key in the map. This so I can step through the map one key at a time.<br><br></div>M = #{a => 1, b => 2, e => 5}.<br></div>maps:first_key(M) ==> a<br></div>maps:next(M, a) ==> {b,2}<br></div>maps:next(M, b) ==> {e,5}<br><br></div>The order is irrelevant. I think the next function might as well return the next key and its value seeing there is no copying and very little extra work and you are probably going to get the value anyway. Yes, I know I can get a list of all the keys but then I need to keep the list somewhere and if it is a big map (which is now feasible) then creating a big list seems a waste.<br><br></div>Without this I can't use maps in a place where they would really fit, in luerl my Lua implementation.<span class="HOEnZb"><font color="#888888"><br><br></font></span></div><span class="HOEnZb"><font color="#888888">Robert<br><br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 29 September 2015 at 10:36, Sergej Jurečko <span dir="ltr"><<a href="mailto:sergej.jurecko@gmail.com" target="_blank">sergej.jurecko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Oh ok. I was under the impression maps have sorted keys.<span><font color="#888888"><br><br><br></font></span></div><span><font color="#888888">Sergej<br></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 29, 2015 at 10:32 AM, zxq9 <span dir="ltr"><<a href="mailto:zxq9@zxq9.com" target="_blank">zxq9@zxq9.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Tuesday 29 September 2015 10:12:55 Sergej Jurečko wrote:<br>
> Something like gb_trees:iterator_from<br>
> If you're traversing the entire map then to_list is fine (which fold,map<br>
> use). But if you wish to only traverse a subset of k/v pairs in a large map<br>
> it is quite wasteful.<br>
<br>
</span>Map keys are unordered. GB tree keys are ordered.<br>
<br>
If you are using maps then something like iterator_from already does not fit. But maybe you have some subset of keys you want to traverse? That is what maps:with/2 and maps:without/2 are for. (I have no idea how efficient with/2 or without/2 are in gigantic maps in R18 -- but I imagine these are the functions that will be optimized to death eventually if anything is, so it is what I would write code against today. Unless you actually do just need gb_trees...)<br>
<br>
In some cases having maps:partition/2 would be nice, but there are no cases I can think of where an equivalent to iterator_from makes sense without either requiring a filter over the entire map's values to figure out what subset you want, or already having a sublist of keys you want to include or exclude from your traversal.<br>
<br>
What am I missing?<br>
<br>
-Craig<br>
<div><div>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a 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>
</div></div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>