<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi,<br>
</p>
<p>i guess <b>we</b> do all the same,</p>
<p>1) processes with propery Y, i have about 1-10 million processes<br>
2) gen_server to manage these processes in maps,dict,lists for
example a pool with in,out,leave,delete<br>
3) monitoring these processes<br>
</p>
<p>Dilemma: <br>
</p>
<p>If process P died i have to delete it from data structure using
in 2)<br>
<br>
- maps, dict very fast; <br>
lists -> List -- [Item] slow!<br>
OK, i could use a sorted list and and the subtract would be
faster, but insert is then slower!<br>
And subtract need an algorithm!<br>
<br>
- i do not want a special process, only one random or the first
one from data structure using in 2)<br>
here is the place where i need <b>first_from_data_structure</b><br>
<b> </b>lists very fast: first defines it itself ->
[First|Rest] = List,<br>
but using maps or dict there is not first, at all!</p>
<p>The question is: How can i get a random or first item from maps
or dict?</p>
<p>Hope that helps!</p>
<p>Oliver <br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 13.08.19 15:41, Lukas Larsson wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAP3zBqMO0qWni+5q=N-rAnvRmmox7TGK16SZKr-YarbqUzdt_Q@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Aug 13, 2019 at 3:34
PM Oliver Bollmann <<a
href="mailto:oliver.bollmann@t-online.de"
moz-do-not-send="true">oliver.bollmann@t-online.de</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>I often need <a
class="gmail-m_-4002335776611155796moz-txt-link-freetext"
moz-do-not-send="true">maps:first(Map)</a>, is there
plan for it?</p>
</div>
</blockquote>
<div><br>
</div>
<div>No, there is currently no plan for it, as I cannot think
of a use case when it would be useful, but that might just
be poor imagination on my part.</div>
<div><br>
</div>
<div>What do you use <a class="moz-txt-link-freetext" href="maps:first">maps:first</a> for?</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>My current implementation is: </p>
<pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:Menlo">first(<span style="color:rgb(102,14,122)">Map</span>) ->
<span style="color:rgb(0,0,128);font-weight:bold">case </span><a class="gmail-m_-4002335776611155796moz-txt-link-freetext" moz-do-not-send="true">maps:next(maps:iterator(</a><span style="color:rgb(102,14,122)">Map</span>)) <span style="color:rgb(0,0,128);font-weight:bold">of
</span><span style="color:rgb(0,0,128);font-weight:bold"> </span>{<span style="color:rgb(102,14,122)">Key</span>,<span style="color:rgb(102,14,122)">Val</span>,<span style="color:rgb(102,14,122)">_</span>} -> {<span style="color:rgb(102,14,122)">Key</span>,<span style="color:rgb(102,14,122)">Val</span>};
none -> none
<span style="color:rgb(0,0,128);font-weight:bold">end.
Create </span><span style="color:rgb(0,0,128);font-weight:bold"><span style="color:rgb(0,0,128);font-weight:bold">the iterator</span> always a new map?
</span></pre>
<pre class="gmail-m_-4002335776611155796moz-signature" cols="72">--
Grüße
Oliver Bollmann</pre>
</div>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank"
moz-do-not-send="true">erlang-questions@erlang.org</a><br>
<a
href="http://erlang.org/mailman/listinfo/erlang-questions"
rel="noreferrer" target="_blank" moz-do-not-send="true">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote>
</div>
</div>
</blockquote>
<pre class="moz-signature" cols="72">--
Grüße
Oliver Bollmann</pre>
</body>
</html>