OK thanks guys.<br><br><div class="gmail_quote">On Wed, Feb 29, 2012 at 3:29 PM, Richard Carlsson <span dir="ltr"><<a href="mailto:carlsson.richard@gmail.com">carlsson.richard@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><div></div><div class="h5">On 02/29/2012 04:20 PM, Pierpaolo Bernardi wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Feb 29, 2012 at 16:13, Richard Evans<br>
<<a href="mailto:richardprideauxevans@gmail.com" target="_blank">richardprideauxevans@gmail.<u></u>com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I need to store a list of records. Sometimes I need to update the nth member<br>
in that list. Each record is quite large (hundreds of bytes). I have<br>
hundreds of such records.<br>
<br>
I am currently using an erlang list and using lists:keyreplace to update the<br>
nth member in the list. But this gets slow as the list gets larger, so I<br>
want to optimize and use something which overwrites rather than copies.<br>
<br>
Should I use the array module for this? If not, what do you recommend?<br>
</blockquote>
<br>
a gb-tree with keys in 1..n.<br>
<br>
Or a random-access list. Not in stdlib, but several implementations<br>
floating around, including one from me. Ask me if you don't find one.<br>
</blockquote>
<br></div></div>
Why? The array module is basically using the same techniques as the gb_trees module, except that it is optimized for keys in 0..N. (For one thing, it doesn't need to actually store the keys - it can compute the position in the tree given the key, so it uses less storage and fewer comparisons.) The array module also handles sparse arrays just fine, so the keys don't have to be a dense range.<br>
<font color="#888888">
<br>
/Richard</font><div><div></div><div class="h5"><br>
______________________________<u></u>_________________<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" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br>