<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dictionary object in pd-extended?]]></title><description><![CDATA[<p>Hi all!</p>
<p>I was wondering of there is a simple dictionary (key-&gt; value storage) object in pd-extended. Something with basically operations &quot;set <em>key</em>&quot;, &quot;get <em>key</em>&quot; and &quot;delete <em>key</em>&quot;</p>
<p>Any idea what I could use?</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 19:44:26 GMT</lastBuildDate><atom:link href="http://forum.pdpatchrepo.info/topic/8836.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 07 Dec 2014 19:08:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sun, 07 Dec 2014 19:08:37 GMT]]></title><description><![CDATA[<p>Hi all!</p>
<p>I was wondering of there is a simple dictionary (key-&gt; value storage) object in pd-extended. Something with basically operations &quot;set <em>key</em>&quot;, &quot;get <em>key</em>&quot; and &quot;delete <em>key</em>&quot;</p>
<p>Any idea what I could use?</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended</guid><dc:creator><![CDATA[sebpiq]]></dc:creator><pubDate>Sun, 07 Dec 2014 19:08:37 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sun, 07 Dec 2014 21:01:15 GMT]]></title><description><![CDATA[<p>What about [coll] ?</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/2</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/2</guid><dc:creator><![CDATA[bang]]></dc:creator><pubDate>Sun, 07 Dec 2014 21:01:15 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sun, 07 Dec 2014 21:41:52 GMT]]></title><description><![CDATA[<p>[coll] is more of a list really. Indexes are Integers. I have indexes that are symbols. and I want to associate them with other symbols.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/3</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/3</guid><dc:creator><![CDATA[sebpiq]]></dc:creator><pubDate>Sun, 07 Dec 2014 21:41:52 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Mon, 08 Dec 2014 07:11:37 GMT]]></title><description><![CDATA[<p>did you try  pdcontainer like [h_multimap] ?</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/4</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/4</guid><dc:creator><![CDATA[bang]]></dc:creator><pubDate>Mon, 08 Dec 2014 07:11:37 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Tue, 09 Dec 2014 01:41:13 GMT]]></title><description><![CDATA[<p>aside from h_multimap and h_map you could try using pdlua and write a simple  class because in lua associative tables are a primitive type and are generally well implemented <a href="http://lua-users.org/wiki/TablesTutorial" rel="nofollow">http://lua-users.org/wiki/TablesTutorial</a></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/5</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/5</guid><dc:creator><![CDATA[seb-harmonik.ar]]></dc:creator><pubDate>Tue, 09 Dec 2014 01:41:13 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sun, 14 Dec 2014 11:16:25 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/bang">@bang</a> sorry! Slow to answer ... I don't know about [h_multimap] it's not in pd-extended right?</p>
<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/seb-harmonik-ar">@seb-harmonik-ar</a> I don't really want to get into that. Feels a bit complicated for such a simple thing.</p>
<p>I kind of thought it's such a common thing to do with general purpose programming languages, that there must be an object implementing it in pd-extended .... but apparently there might not be!?</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/6</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/6</guid><dc:creator><![CDATA[sebpiq]]></dc:creator><pubDate>Sun, 14 Dec 2014 11:16:25 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sun, 14 Dec 2014 19:32:30 GMT]]></title><description><![CDATA[<p>But Pd is not a general purpose programming language, or at least it's not really meant to be...no?</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/7</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/7</guid><dc:creator><![CDATA[alexandros]]></dc:creator><pubDate>Sun, 14 Dec 2014 19:32:30 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Tue, 23 Dec 2014 21:01:10 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/sebpiq">@sebpiq</a> said:</p>
<blockquote>
<p>[coll] is more of a list really. Indexes are Integers. I have indexes that are symbols. and I want to associate them with other symbols.</p>
</blockquote>
<p>[coll] is actually an associative array and can associate symbols with symbols. Yo can use it with floats as indices, and some messages give the impression it is an array. The help-patch is very confusing in this. I tried to make an improved version: <a href="http://fjkraan.home.xs4all.nl/digaud/puredata/cyclone/help-patches/coll-help.pd" rel="nofollow">http://fjkraan.home.xs4all.nl/digaud/puredata/cyclone/help-patches/coll-help.pd</a></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/8</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/8</guid><dc:creator><![CDATA[electrickery]]></dc:creator><pubDate>Tue, 23 Dec 2014 21:01:10 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Fri, 30 Jan 2015 01:33:51 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/sebpiq">@sebpiq</a> <a href="http://forum.pdpatchrepo.info/topic/8993/lmap-interface-to-lua-s-associative-array-a-k-a-map-structure-using-pdlua">http://forum.pdpatchrepo.info/topic/8993/lmap-interface-to-lua-s-associative-array-a-k-a-map-structure-using-pdlua</a><br />
here's a lua version</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/9</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/9</guid><dc:creator><![CDATA[seb-harmonik.ar]]></dc:creator><pubDate>Fri, 30 Jan 2015 01:33:51 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Fri, 06 Feb 2015 14:16:14 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/sebpiq">@sebpiq</a> what about something like this, Seb? <a href="http://forum.pdpatchrepo.info/topic/8122/slider-value-reference-to-a-list/3">http://forum.pdpatchrepo.info/topic/8122/slider-value-reference-to-a-list/3</a></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/10</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/10</guid><dc:creator><![CDATA[gsagostinho]]></dc:creator><pubDate>Fri, 06 Feb 2015 14:16:14 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Thu, 12 Feb 2015 17:27:36 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/sebpiq">@sebpiq</a> I made one of these for a library I'm working on - it has exactly the syntax you want plus some more things:</p>
<p><a href="https://drive.google.com/open?id=0B3cukQjg0M-oSklvSXBCTm1ETFk" rel="nofollow">dictionary-standalone.pd</a><br />
<a href="https://drive.google.com/open?id=0B3cukQjg0M-oRjFEMUhYVGdHT0E" rel="nofollow">dictionary-standalone-help.pd</a></p>
<p>It's &quot;standalone&quot; because the actual [dictionary] object uses a bunch of external patches that were replaced with [pd ] subpatches.</p>
<p>If you're interested, I have a bunch of those patches here (I'll update it with a Github link soon):</p>
<p><a href="https://drive.google.com/open?id=0B3cukQjg0M-oSlpGLWRCVG5xekE&amp;authuser=0" rel="nofollow">Pd Patches - Google Drive</a></p>
<p>With the [environments] object, you can have key-value bindings where the values are [dictionary] objects (using dynamic patching).  [abstractions] lets you put your own subpatch as the value instead of a [dictionary].</p>
<p>Edit: Here's a standalone version of [abstractions] (that's also vanilla compatible):</p>
<p><a href="https://drive.google.com/open?id=0B3cukQjg0M-oSDVSWEtBM2h0VE0&amp;authuser=0" rel="nofollow">abstractions-standalone.pd</a><br />
<a href="https://drive.google.com/open?id=0B3cukQjg0M-oNC16SERaWF8wcHc&amp;authuser=0" rel="nofollow">abstractions-standalone-help.pd</a></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/11</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/11</guid><dc:creator><![CDATA[cpenny42]]></dc:creator><pubDate>Thu, 12 Feb 2015 17:27:36 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Wed, 08 May 2019 19:25:35 GMT]]></title><description><![CDATA[<p>i tried to make something like a basic dictionary with the [text] object (i am not sure if my attempt makes sense): <a href="/uploads/files/1557343513992-dict.pd">dict.pd</a><br />
<img src="/uploads/files/1557343530082-dict.png" alt="dict.PNG" class="img-responsive img-markdown" /></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/12</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/12</guid><dc:creator><![CDATA[Jona]]></dc:creator><pubDate>Wed, 08 May 2019 19:25:35 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Thu, 09 May 2019 01:59:34 GMT]]></title><description><![CDATA[<p>i put everything into one abstraction. i think it has the basic functionality from zexys [coll]. so basically a poor vanilla coll version.<br />
but missing features are perhaps possible to implement. <a href="/uploads/files/1557367172506-vcoll.pd">vColl.pd</a><br />
<img src="/uploads/files/1557366032749-dict2.png" alt="dict2.PNG" class="img-responsive img-markdown" /></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/13</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/13</guid><dc:creator><![CDATA[Jona]]></dc:creator><pubDate>Thu, 09 May 2019 01:59:34 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Fri, 10 May 2019 06:01:24 GMT]]></title><description><![CDATA[<p>again, as <a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/electrickery">@electrickery</a> said, [coll] is actually an associative array and can associate symbols with symbols.</p>
<p>why are you still using extended? it carries a very old cyclone library, for instance, with 0.1 versions <a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/electrickery">@electrickery</a> ressurected it back and made a great 0.2 release, me and others have carried on and now there's a 0.3 version you can use in vanilla. But anyway, I guess coll will work for what you want in Pd extended anyhow...</p>
<p>cheers</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/14</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/14</guid><dc:creator><![CDATA[porres]]></dc:creator><pubDate>Fri, 10 May 2019 06:01:24 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Fri, 10 May 2019 13:27:11 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/porres">@porres</a> actually i do do not use pd extended at all. and of course [coll] is a nice external that has more features than my abstraction.<br />
also my abstraction would not work with pd extended, because it uses newer objects.<br />
i just like the idea to build things with pd vanilla if it is not much more inefficient than using externals.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/15</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/15</guid><dc:creator><![CDATA[Jona]]></dc:creator><pubDate>Fri, 10 May 2019 13:27:11 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Fri, 10 May 2019 15:25:23 GMT]]></title><description><![CDATA[<p>sure, but I was actually replying to <a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/sebpiq">@sebpiq</a></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/16</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/16</guid><dc:creator><![CDATA[porres]]></dc:creator><pubDate>Fri, 10 May 2019 15:25:23 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sat, 11 May 2019 19:52:31 GMT]]></title><description><![CDATA[<p>I wonder if it would be worth it to abstract out the hashing mechanism of gensym in m_class.c and make a class to access it.</p>
<p>Something like:</p>
<p>[symbol hello(<br />
|<br />
[symhash 1000]<br />
|<br />
[print result]</p>
<p>That would give you the hash for &quot;hello&quot; modulo 1000 which you could use to implement a fairly performant dictionary in Pd Vanilla. (You can do it manually but it's a bit slow to split the symbol and add the ASCII value of each character in an object chain.)</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/17</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/17</guid><dc:creator><![CDATA[jancsika]]></dc:creator><pubDate>Sat, 11 May 2019 19:52:31 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sat, 11 May 2019 21:32:17 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/jancsika">@jancsika</a> i do not know a lot about hash algorhitms but your idea sounds useful.<br />
three questions:<br />
are a dictionary and a hash map basically the same?<br />
why would you use modulo 1000?<br />
and if you have the hashes of a list of symbols/strings is it possible to sort them easily alphabetically then?</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/18</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/18</guid><dc:creator><![CDATA[Jona]]></dc:creator><pubDate>Sat, 11 May 2019 21:32:17 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sun, 12 May 2019 01:14:22 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/jona">@Jona</a> Sorry, I'm not up on my CS terminology but I'll do my best.</p>
<p>A hash map is a type of dictionary, and a dictionary as I understand it is basically a bunch of key/value pairs.</p>
<p>For a real-time system you want to be able to take a key as input and output the value in an amount of time that is small and predictable. You also want the performance to be about the same regardless of how many keys you have or whether a particular key is at the beginning or end of the data.</p>
<p>Suppose I have an array of 10,000 key/value pairs and I want to find the value for key &quot;blah.&quot; An easy way to search would be to start at the beginning and iterate through each element until I find the key named &quot;blah.&quot; If the key is at element 0 then it's as fast as possible, but if it's at element 9,999 it's much slower (because I had to iterate through the entire array before I found it). If we want the lookup time to be constant that's not a good algorithm, and it gets worse the more elements we add.</p>
<p>A hashing function will take something like one of our keys and &quot;hash&quot; it to some value<br />
in a fixed range. So &quot;foo&quot; might hash to the number 12, &quot;blah&quot; to 450, and so on. The point<br />
is that the input can be an arbitrary string, and the output will be a number between,<br />
say, 1 and 1,000. The mapping of strings to numbers should ideally happen in a way that<br />
distributes our keys uniformly between 1 and 1,000. But it should also be predictable<br />
so that when we hash the same string we always get the same number out.</p>
<p>Since we have 10,000 keys and only 1,000 total slots, we'll still get multiple key/value<br />
pairs in each slot. But now instead of our worst case of iterating through 9,999 keys,<br />
we have</p>
<ol>
<li>time it takes to compute the hash and find the slot where our key/value pair is. (For Pd symbols, the hashing algo is essentially just doing two addition ops per character of the string, then a modulo op. That usually takes a lot less time than iterating through a big array of symbols to find a match.)</li>
<li>time it takes to iterate through 10 keys (on average) for that slot.</li>
</ol>
<p>That's much better performance for a real-time system. And we can decrease our<br />
average iteration from 10 to 1 by using 10,000 slots instead of 1,000, at the expense of more memory. (And possibly worse cache performance, though I'm not sure about the particulars of that.)</p>
<p>To sum up, there are a few variables:</p>
<ol>
<li>How many slots do you want? Fewer means less memory allocation up front at the<br />
expensive of (potentially) longer time to find/set/remove key/value pairs in each slot.</li>
<li>How much data do you have? For small number of key/value pairs you can probably simply use a much simpler data structure and forgo hash maps altogether. For enormous amounts of key/value pairs, memory may be a limiting factor.</li>
</ol>
<p>There are all kinds of hashing algorithms, a bit of a rabbit hole like DSP filters. I would guess some are better for situations where you may want to sort keys as well as generally efficient performance, etc. But I haven't studied them in depth.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/19</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/19</guid><dc:creator><![CDATA[jancsika]]></dc:creator><pubDate>Sun, 12 May 2019 01:14:22 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sun, 12 May 2019 02:30:53 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/jancsika">@jancsika</a> thanks a lot for your explanations. so basically a hashing function is used because it is faster to find a number than a string (that consist of a list of numbers)? i tried to build a slow vanilla version (the [expr] object should generate the hash number). the values are symbols transformed to lists because i thought about how to sort them alphabetically, but perhaps that is not a good task for pure data (and also not necessary for me at the moment): <a href="/uploads/files/1557628244445-hash.pd">hash.pd</a><br />
<img src="/uploads/files/1557628250927-hash.png" alt="hash.PNG" class="img-responsive img-markdown" /></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/20</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/20</guid><dc:creator><![CDATA[Jona]]></dc:creator><pubDate>Sun, 12 May 2019 02:30:53 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sun, 12 May 2019 05:40:02 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/jona">@Jona</a> Well, in your example you'd probably want to use the hash value to set the line number.</p>
<p>But the problem with your <code>[text]</code>-based approach is that each line is just a list of atoms. It would be possible to just design it so that each line alternates &quot;key1 value1 key2 value2 etc.&quot; but that's clunky to manipulate.</p>
<p>What I think could work would be to create a data structure array where each element has a text field. Then you use the hash to find the array index, and use the key to search that text field for the relevant line, add lines, delete lines, etc.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/21</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/21</guid><dc:creator><![CDATA[jancsika]]></dc:creator><pubDate>Sun, 12 May 2019 05:40:02 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Sun, 12 May 2019 12:42:00 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/jancsika">@jancsika</a> okay, thanks for the clarification ( i am quite new to those terms).</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/22</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/22</guid><dc:creator><![CDATA[Jona]]></dc:creator><pubDate>Sun, 12 May 2019 12:42:00 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Tue, 14 May 2019 14:44:47 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/jancsika">@jancsika</a> i have to admit the data structure array attempt sounds very interesting, but i think it could be quite complicated?<br />
somehow it seems also possible to use data structures with [text search] and other [text] objects (at least you can set a struct flag), but i have not seen any examples yet. but it is possible to use and manipulate data structure arrays with [array] (with an -s flag and the data structure array pointer).<br />
perhaps your idea with the [symhash] object would be the easiest solution for a hash map dictionary?<br />
and i wonder if text [text search] does use kind of a hash function? at least it is faster than sequence and get.<br />
here is a small test. it searches for the symbol house in a text with 30003 lists: <a href="/uploads/files/1557776562633-searchtest.pd">searchtest.pd</a><br />
<img src="/uploads/files/1557776572203-searchtest.png" alt="searchtest.PNG" class="img-responsive img-markdown" /><br />
as part of a ofelia lua script i used another dictionary with pure data (i copied the code from somewhere without totally understanding it, but it worked):</p>
<pre><code>;
-- make dictionary;
;
local function defaultdict(default_value_factory);
;
local t = {};
local metatable = {};
metatable.__index = function(t, key);
if not rawget(t, key) then;
rawset(t, key, default_value_factory(key));
end;
return rawget(t, key);
end;
return setmetatable(t, metatable);
end;
;
</code></pre>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/23</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/23</guid><dc:creator><![CDATA[Jona]]></dc:creator><pubDate>Tue, 14 May 2019 14:44:47 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Mon, 13 May 2019 21:43:18 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/jona">@Jona</a> 1.82 ms isn't fast enough for realtime. That's well over the budget for a single block at Pd's default sample rate. <code>[text search]</code> is almost certainly doing a linear search through each line to get that kind of result.</p>
<p>I'll see if I can throw together an example later.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/24</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/24</guid><dc:creator><![CDATA[jancsika]]></dc:creator><pubDate>Mon, 13 May 2019 21:43:18 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Tue, 14 May 2019 03:30:35 GMT]]></title><description><![CDATA[<p>Sorry, but a segfault with data structures prevents me from implementing a demo.</p>
<p>However, to hash a 4 character string in a Pd patch (using the same method that Pd uses internally for symbol lookup), the worst case realtime performance I measured is 0.088. That hash is then used as an array index to get a pointer to the correct text. Then it's just <code>[text search]</code> and <code>[text get]</code>, where the average search length will be 5 instead of 5000.</p>
<p>Looking at your realtime result for <code>[text search]</code>, it seems likely that a search among 5 or 10 lines is going to be performant enough to calculate easily in realtime. (Although I guess there's still a rather unlikely possibility that all the values get stored at the same exact index. I don't know how to calculate that probability, but it seems extremely unlikely on the face of it.)</p>
<p>Edit: here's a quick example of the hashing algorithm implemented in Pd. Would be a lot faster in C without Pd's message passing.</p>
<p><a href="/uploads/files/1557803771987-hasher.pd">hasher.pd</a></p>
<p>Another edit: This isn't quite the same as the internal algorithm because I'm serializing the string backwards. (For a robust implementation you'd want to use [list-drip] to avoid stack overflows.)</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/25</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/25</guid><dc:creator><![CDATA[jancsika]]></dc:creator><pubDate>Tue, 14 May 2019 03:30:35 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Tue, 14 May 2019 23:13:44 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/jancsika">@jancsika</a> that looks like it could be a good optimization <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/grinning.png" title=":)" alt=":)" /> using list-drip (with list-store) instead should not be the problem.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/26</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/26</guid><dc:creator><![CDATA[Jona]]></dc:creator><pubDate>Tue, 14 May 2019 23:13:44 GMT</pubDate></item><item><title><![CDATA[Reply to Dictionary object in pd-extended? on Thu, 16 May 2019 01:06:09 GMT]]></title><description><![CDATA[<p>Hopefully this will shed some light on what I've been talking about:</p>
<p><a href="/uploads/files/1557967465258-dictionary.pd">dictionary.pd</a><br />
<a href="/uploads/files/1557967472095-dictionary-help.pd">dictionary-help.pd</a></p>
<p>A few things to notice:</p>
<ol>
<li>Search performance should be at least 10x faster than the worst case for <code>[text search]</code></li>
<li>The total computation time for <code>[dictionary]</code> should be vastly more predictable than <code>[text search]</code>.</li>
</ol>
<p>However, there's still a clear bottleneck in this abstraction-- calculating the hash. Not sure whether it's the conversion from symbol to list or the recursive addition, but it is slow. So slow that if you reimplement it in C as I did to test, you get another 10x speed increase.</p>
<p>So exposing the (C level) symbol hashing to the user and wrapping it in an abstraction as I've done should give you a 100x speedup over the worst case linear lookup time in your patch above with 10,000 items.</p>
<p>A more dramatic restatement of that-- since memory is cheap, this means you can create a much larger hashmap and handle an enormous number key/value pairs for realtime computation that would not be possible with linear lookup times of [text].</p>
<p>Edit: the abstraction is just a demo. It will happily duplicate keys (preventable by adding a <code>[text search]</code> in the right object chain), and provides no mechanism to delete entries. While lookup is tweaked for realtime performance, adding keys will cause intermittent memory allocation.</p>
<p>Edit2: This is basically the way <code>t_symbol *gensym(char*)</code> works in the Pd code. It hashes the string to get the array index, then searches through the linked list of symbols at that index for the string. If it finds it it returns the memory address; if not, it creates a new entry and returns that address. That's why you can compare two symbols in Pd source code with &quot;==&quot; sign-- if they're both at the same address then it's the same string.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/27</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8836/dictionary-object-in-pd-extended/27</guid><dc:creator><![CDATA[jancsika]]></dc:creator><pubDate>Thu, 16 May 2019 01:06:09 GMT</pubDate></item></channel></rss>