<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">What about an ets ordered set table?<div><br></div><div>/Tony</div><div><br><div><div>On 27 maj 2014, at 12:58, Joe Armstrong <<a href="mailto:erlang@gmail.com">erlang@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><br></div>What's the best data structure to support a "nearest key" operation?<br><br>I want a data structure that supports the following operations:<br><br> new() -> NewTree<br><br>
insert(Key, Value, Tree) -> NewTree<br> <br> delete(Key, Tree) -> NewTree<br> <br> nearest(Key, N, Tree) -> [{Key1,Val1},{Key2,Val2} ...].<br><br> Keys are 20 byte binaries, values are 6 byte binaries<div>
<br></div><div> The maximum number of keys of Key-Value pairs is 10 million.<br><br> nearest(Key, N, Tree) returns the N nearest items to Key in the tree<br><br> "near" means that the keys are near to each other. Often the key I want will not<br>
be in the tree, so I want nearby keys. The nearness measure is just the<br>"distance" between the two keys (ie the nearest N keys to the given key if the keys were to<br>be sorted)<br><br>Are there any Erlang libraries that do this?<br>
<br>/Joe<br></div></div>
_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>http://erlang.org/mailman/listinfo/erlang-questions<br></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; ">"Installing applications can lead to corruption over time. </span><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; ">Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix"</span></div><div><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; "><br></span></div></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>