<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>Cycling 74  &#187;  Topic: multidimensional array anxiety</title>
		<atom:link href="http://cycling74.com/forums/topic/multidimensional-array-anxiety/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/feed</link>
		<description></description>
		<pubDate>Tue, 18 Jun 2013 18:17:33 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-25924</guid>
					<title><![CDATA[multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-25924</link>
					<pubDate>Thu, 11 May 2006 14:40:03 +0000</pubDate>
					<dc:creator>jbm</dc:creator>

					<description>
						<![CDATA[
						<p>I&#8217;m trying to load an array like:</p>
<p>array[i][j][k][l] = this+that+the+other;</p>
<p>this, that, the, and other are all Atoms.</p>
<p>I get an error that I can&#8217;t use &#8220;+&#8221; on Atoms.</p>
<p>I&#8217;m certainly confused about all this, but I thought the concatenation was just used to load multidimensional arrays. Is that wrong? Is it actually trying to add them? I have been looking at all sorts of examples on the internet, but I can&#8217;t find anything terribly helpful. Can anyone explain to me how I&#8217;m supposed to load a 4D array?</p>
<p>J.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76946</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76946</link>
					<pubDate>Thu, 11 May 2006 15:29:17 +0000</pubDate>
					<dc:creator>nick rothwell / cassiel</dc:creator>

					<description>
						<![CDATA[
						<p>That&#8217;s absolutely correct. &#8220;+&#8221; is not defined on Atoms. I don&#8217;t see  <br />
what this error has to do with multidimensional arrays. Are you  <br />
trying to load an entire row at once?</p>
<p>
   nick rothwell &#8212; composition, systems, performance &#8212; http:// <br />
<a href="http://www.cassiel.com" rel="nofollow">http://www.cassiel.com</a></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76947</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76947</link>
					<pubDate>Thu, 11 May 2006 16:00:01 +0000</pubDate>
					<dc:creator>jbm</dc:creator>

					<description>
						<![CDATA[
						<p>Oh my God! If I&#8217;ve got your ear, Nick, I might actually try to explain my problem in a little more detail, since I don&#8217;t even know that a multidimensional array will do the trick (and I&#8217;ve been at this, literally, all day&#8230;)</p>
<p>I&#8217;ve got a bunch of flat database files. Just text. Each line is something like this:</p>
<p>20 3 -6 60|64 64 64 0|&#8221;/path/to/a/sample_C4.wav&#8221;</p>
<p>The first field describes basic musical attributes. The second, CC vales. The third, a path (obviously!). I&#8217;m trying to pull &#8220;ranges&#8221; out of these flat files, in the sense that I want to get into the ballpark, but not get one precise sample &#8212; if I use both fields 1 and 2, I get a precise mapping. I can get a ballpark using only the first field, which will give me colour, dynamic, interval, and pitch &#8212; which will be common to a number of samples. What I can&#8217;t seem to do is to find a good way of storing/recalling any entry that matches only the first field. Or, put another way, I need a collection that will map one key to many values.<br />
If I hash entries by only the first field, then I lose a bunch of entries (the same hash just keeps getting over-written). If I hash by the full path, then it seems very awkward to work my way back to the first two fields&#8230; Does that make any sense? I know, this all sounds like very basic &#8220;one->many&#8221;, &#8220;many->many&#8221; database stuff, but it&#8217;s doing my head in!<br />
Anyway, what I&#8217;m precisely trying to do is build a collection or stucture of some sort where I can get all entries/lines with a common field 1. </p>
<p>Any thoughts? Even if you can just point me in the right direction, I&#8217;d really appreciate it.</p>
<p>cheers,</p>
<p>J.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76948</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76948</link>
					<pubDate>Thu, 11 May 2006 16:04:40 +0000</pubDate>
					<dc:creator>Wesley Smith</dc:creator>

					<description>
						<![CDATA[
						<p>Create a HashMap object with the key you want and a heterogenous<br />
ArrayList as the value.</p>
<p>wes</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76949</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76949</link>
					<pubDate>Thu, 11 May 2006 16:24:02 +0000</pubDate>
					<dc:creator>jbm</dc:creator>

					<description>
						<![CDATA[
						<p>So my key is <field 1> and my value is an ArrayList containing every line sharing that same </field><field 1>&#8230; Holy crap. Could that have been any simpler? Sometimes, the harder you try, the wider the gulf between will and reason becomes&#8230; ouch.</field></p>
<p>Considering the format of field 1 (a string of 4 ints), would you use an equals(), or code something by hand to compare them? Just curious.</p>
<p>thanks, wes.</p>
<p>J.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76950</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76950</link>
					<pubDate>Thu, 11 May 2006 17:08:39 +0000</pubDate>
					<dc:creator>Wesley Smith</dc:creator>

					<description>
						<![CDATA[
						<p>No prob,<br />
I would highly recommend reading these pages:<br />
<a href="http://www.javapractices.com/Topic17.cjp" rel="nofollow">http://www.javapractices.com/Topic17.cjp</a></p>
<p><a href="http://www.javapractices.com/Topic28.cjp" rel="nofollow">http://www.javapractices.com/Topic28.cjp</a></p>
<p>I used them for a MetaImage.java class.  Here&#8217;s the code:<br />
<a href="http://www.mat.ucsb.edu/~whsmith/EqualsHashExample.zip" rel="nofollow">http://www.mat.ucsb.edu/~whsmith/EqualsHashExample.zip</a></p>
<p>You can do something similar with a lightweight class for your key object.</p>
<p>best,<br />
wes</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76951</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76951</link>
					<pubDate>Sat, 13 May 2006 11:58:44 +0000</pubDate>
					<dc:creator>jbm</dc:creator>

					<description>
						<![CDATA[
						<p>So, I&#8217;ve got the following code, which is intended to check whether an entry exists. If not, add it (as an ArrayList).<br />
If so, get the current ArrayList at that key, add the new<br />
input to it, and put the whole thing back in the DB.</p>
<p>The problem is, I get multiple repetitions of the _last_<br />
input, basically over-writing everything previously entered.<br />
This is a familiar pattern, from creating an object at the<br />
wrong point in the code (or re-using an object when I should<br />
be creating a new instance), but I can&#8217;t see where I&#8217;m<br />
messing up(?). Maybe it&#8217;s obvious&#8230;</p>
<p>
private HashMap<string ,ArrayList> looseDB = new HashMap</string><string ,ArrayList>();</string></p>
<p>private void buildLooseDB(String shortAttrList, Atom[] CCList_fullpath)<br />
	{<br />
	if(!looseDB.containsKey(shortAttrList))					// if this shortAttrList isn&#8217;t in DB<br />
		{<br />
		ArrayList addLooseEvent = new ArrayList();<br />
		addLooseEvent.add(CCList_fullpath);<br />
		looseDB.put(shortAttrList,addLooseEvent);			// add it to DB<br />
		} else {											// otherwise,</p>
<p>		extendLooseEventEntry = new ArrayList();<br />
		extendLooseEventEntry = looseDB.get(shortAttrList);	// get the current entry, at this key	<br />
		extendLooseEventEntry.add(CCList_fullpath);			// add a new item (the input) to it<br />
		looseDB.put(shortAttrList,extendLooseEventEntry);	// and put the revised entry back in DB<br />
		}<br />
	}</p>
<p>thanks in advance,</p>
<p>J.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76952</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76952</link>
					<pubDate>Sat, 13 May 2006 12:31:48 +0000</pubDate>
					<dc:creator>nick rothwell / cassiel</dc:creator>

					<description>
						<![CDATA[
						<p>For what it&#8217;s worth,</p>
<p>> 		extendLooseEventEntry = new ArrayList();<br />
> 		extendLooseEventEntry = looseDB.get(shortAttrList);</p>
<p>this code (and the following few lines) suggests a misunderstanding.  <br />
Once you&#8217;ve assigned extendLooseEventEntry (the second time) it&#8217;s  <br />
pointing directly at the object in the HashMap, so (i) the first  <br />
assignment is superfluous and (ii) you don&#8217;t need to do the put().</p>
<p>
   nick rothwell &#8212; composition, systems, performance &#8212; http:// <br />
<a href="http://www.cassiel.com" rel="nofollow">http://www.cassiel.com</a></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76953</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76953</link>
					<pubDate>Sat, 13 May 2006 21:29:55 +0000</pubDate>
					<dc:creator>jbm</dc:creator>

					<description>
						<![CDATA[
						<p>Well, a &#8220;misunderstanding&#8221; doesn&#8217;t surprise me in the least; the documentation, and most of the literature on programming in general, seems to have been written for the phys-ed of word processors. &#8220;For what it&#8217;s worth&#8221;??? Well&#8230; a hell of a lot, really!!! </p>
<p>So, when I call &#8220;get&#8221;, am I just pulling out a reference to the object that&#8217;s still in the hashMap, not a copy of the object? I was always under the (mis)understanding that I was getting a copy that I had to do something with, then &#8220;put&#8221; back. If I can operate directly on the object, while it&#8217;s in the hashMap, life would certainly be alot simpler! Does this mean that I can call &#8220;add&#8221; on the ArrayList directly, just by referencing the object&#8217;s name? That would be really, really, really, cool.</p>
<p>Sorry if I sound like an idiot&#8230; though, to be quite honest, I don&#8217;t feel too badly about it. It makes perfect sense to think that if one stores something in a certain location, they&#8217;ll have to go &#8220;get&#8221; it if they want to do anything to it, and &#8220;put&#8221; it back when they&#8217;re done. Computer languages seem to demonstrate an  almost diabolical ignorance of human common-sense, with what Lakoff &#038; Johnson refer to as &#8220;conceptual metaphors&#8221; being violated with serial abandon (except, in many cases, with Max, which is why most of us are here!!!).</p>
<p>Anyway, if I&#8217;m in the ballpark now, please let me know. It would be a great help, as you can well imagine if you&#8217;ve read this far!</p>
<p>cheers,</p>
<p>J.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76954</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76954</link>
					<pubDate>Sat, 13 May 2006 21:39:17 +0000</pubDate>
					<dc:creator>Wesley Smith</dc:creator>

					<description>
						<![CDATA[
						<p>> So, when I call &#8220;get&#8221;, am I just pulling out a reference to the object that&#8217;s still in the hashMap, not a copy of the object? I was always under the (mis)understanding that I was getting a copy that I had to do something with, then &#8220;put&#8221; back. If I can operate directly on the object, while it&#8217;s in the hashMap, life would certainly be alot simpler! Does this mean that I can call &#8220;add&#8221; on the ArrayList directly, just by referencing the object&#8217;s name? That would be really, really, really, cool.</p>
<p>
Yes, you can operate directly on the array list when you access it<br />
from the HashMap and your changes will stay there.  I&#8217;m not user this<br />
ir proper JAVA code as it has been a while, but you&#8217;ll ge the idea</p>
<p>Ass u me hasMap has some items in it and that key accesses one of those items:</p>
<p>( (ArrayList)hashMap.get(key) ).add(newItem);</p>
<p>This will add a new item to the ArrayList associated with key in the HashMap.</p>
<p>best,<br />
wes</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76955</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76955</link>
					<pubDate>Sat, 13 May 2006 23:45:54 +0000</pubDate>
					<dc:creator>jbm</dc:creator>

					<description>
						<![CDATA[
						<p>well, well. definitely VERY good to know. Thanks, Wes.</p>
<p>J.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76956</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76956</link>
					<pubDate>Sun, 14 May 2006 13:55:49 +0000</pubDate>
					<dc:creator>jbm</dc:creator>

					<description>
						<![CDATA[
						<p>Okay, so I think I&#8217;ve got the HashMap and ArrayList stuff worked out. But I&#8217;m still getting the same results: every entry in the HashMap appears to be getting the _last_ input. The ArrayLists are the correct length (size()), but each Atom[] in the ArrayList is identical, and it&#8217;s always the last line in the DB file. This still suggests that the entire ArrayList is getting over-written with the last entry. I can&#8217;t see how this could be happening&#8230;</p>
<p>private HashMap<string ,ArrayList> looseDB = new HashMap</string><string ,ArrayList>();</string></p>
<p>private void buildLooseDB(String shortAttrList, Atom[] looseDBEntry)<br />
	{<br />
	if(!looseDB.containsKey(shortAttrList))				// if this shortAttrList isn&#8217;t in DB<br />
		{<br />
		ArrayList eventCandidates = new ArrayList(50);<br />
		post(shortAttrList +&#8221; &#8220;+looseDBEntry[0] +&#8221; &#8221; +looseDBEntry[1] +&#8221; &#8221; +looseDBEntry[2]);<br />
		eventCandidates.add(looseDBEntry);				// add this input to the ArrayList<br />
		looseDB.put(shortAttrList,eventCandidates);		// and put it in the DB.<br />
		} else {										// otherwise,<br />
	 	looseDB.get(shortAttrList).add(looseDBEntry);	// get the existing entry, and add this input<br />
		}<br />
	}</p>
<p>
I&#8217;m checking it using this little method:</p>
<p>public void testOne(String shortAttrList, int index)<br />
	{<br />
	post(&#8220;size: &#8221; +looseDB.get(shortAttrList).size());<br />
	Atom[] tester = (Atom[])looseDB.get(shortAttrList).get(index);<br />
	post(&#8220;&#8221; +tester[0] +&#8221; &#8221; +tester[1] +&#8221; &#8221; +tester[2]);<br />
	}</p>
<p>Sorry for being such a pain, but this is not making sense to me&#8230;</p>
<p>J.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76957</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76957</link>
					<pubDate>Sun, 14 May 2006 17:45:48 +0000</pubDate>
					<dc:creator>nick rothwell / cassiel</dc:creator>

					<description>
						<![CDATA[
						<p>
On 13 May 2006, at 22:29, jbmaxwell wrote:</p>
<p>> I was always under the (mis)understanding that I was getting a copy  <br />
> that I had to do something with, then &#8220;put&#8221; back.</p>
<p>Nope. With the exception of the primitive types (int, bool, float  <br />
etc.) Java does everything by reference.</p>
<p>	&#8211; N.</p>
<p>
   nick rothwell &#8212; composition, systems, performance &#8212; http:// <br />
<a href="http://www.cassiel.com" rel="nofollow">http://www.cassiel.com</a></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76958</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76958</link>
					<pubDate>Sun, 14 May 2006 17:58:36 +0000</pubDate>
					<dc:creator>nick rothwell / cassiel</dc:creator>

					<description>
						<![CDATA[
						<p>
On 14 May 2006, at 14:55, jbmaxwell wrote:</p>
<p>> private void buildLooseDB(String shortAttrList, Atom[] looseDBEntry)</p>
<p>I don&#8217;t see anything obviously wrong with the code, so I&#8217;d have to  <br />
wonder where the Atom[] argument comes from, since you insert a  <br />
reference to it into the hash table.</p>
<p>Erm&#8230; you&#8217;re creating a hash table mapping String to ArrayList<atom <br></atom>
[]>? Is this what you meant?</p>
<p>(I suggest dropping the unchecked dynamic type and qualifying all  <br />
occurrences of ArrayList.)</p>
<p>	&#8211; N.</p>
<p>
   nick rothwell &#8212; composition, systems, performance &#8212; http:// <br />
<a href="http://www.cassiel.com" rel="nofollow">http://www.cassiel.com</a></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76959</guid>
					<title><![CDATA[Re: multidimensional array anxiety]]></title>
					<link>http://cycling74.com/forums/topic/multidimensional-array-anxiety/#post-76959</link>
					<pubDate>Sun, 14 May 2006 23:54:27 +0000</pubDate>
					<dc:creator>jbm</dc:creator>

					<description>
						<![CDATA[
						<p>
> Erm&#8230; you&#8217;re creating a hash table mapping String to ArrayList<atom <br></atom>
> []>? Is this what you meant?<br />
> </p>
<p>AAACK! Well yes, the mapping is what I was after, but your question pointed me in the direction of the problem; it was the Atom[] that was getting screwed up. I was creating the Atom[] itself outside of the loop that was calling this method, meaning that it was always the _same_ Atom[] being sent/referenced. So, I&#8217;m guessing the Atom[] was being over-written once it was already _in_ the ArrayList, which was already _in_ the HashMap(??). That at least makes sense, anyway. I knew it was something like that&#8230; just don&#8217;t know why it took me so long to find it.</p>
<p>Thanks,</p>
<p>J.</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

