<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>techbits.de &#187; programming</title>
	<atom:link href="http://www.techbits.de/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techbits.de</link>
	<description>thoughts on hardware, software, development and tech news</description>
	<lastBuildDate>Thu, 11 Feb 2010 21:37:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>IndexedList: A hybrid of a Java List and a Map</title>
		<link>http://www.techbits.de/2009/07/18/indexedlist-a-hybrid-of-a-java-list-and-a-map/</link>
		<comments>http://www.techbits.de/2009/07/18/indexedlist-a-hybrid-of-a-java-list-and-a-map/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 11:00:09 +0000</pubDate>
		<dc:creator>florian</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[collections]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.techbits.de/?p=164</guid>
		<description><![CDATA[If been working on legacy data import code in the last months with a lot of code searching for exisiting objects in lists. I realized I needed a different collection to speed up searching for identifiers and couldn&#8217;t find any standard collection that matches my needs. I basically need an index like Maps.uniqueIndex() from the [...]]]></description>
			<content:encoded><![CDATA[<p>If been working on legacy data import code in the last months with a lot of code searching for exisiting objects in lists. I realized I needed a different collection to speed up searching for identifiers and couldn&#8217;t find any standard collection that matches my needs. I basically need an index like <span style="font-family: Courier New;">Maps.uniqueIndex()</span> from the <a href="http://code.google.com/p/google-collections/">Google Collections Library</a> provides but it should be updating dynamically and not only be generated once.</p>
<p><span id="more-164"></span>To summarize my requirements:</p>
<ul>
<li>A List (ArrayList) which can be modified as usual</li>
<li>A way to find objects (contains and get) in constant time by a custom attribute (like a HashMap)</li>
<li>No reliance on equals() and hashcode() because they cover more attributes (an can not be changed)</li>
</ul>
<p>The <span style="font-family: Courier New;">LinkedHashMap </span>seems to almost fit the bill but it is not a true List and therefore not a great drop in replacement.</p>
<p>What I&#8217;m using right now is a wrapper around a List which maintains an additional HashMap to find objects by the index criterium. The index is automatically updated whenever the list is modified. This is an example on how I use it:</p>
<blockquote>
<pre>// function to index Persons by their social security number<br style="font-family: Courier New;" />Function&lt;Person, String&gt; getSsnrForPerson =
  new Function&lt;Person, String&gt;() {<br style="font-family: Courier New;" />    String apply(Person person) {<br style="font-family: Courier New;" />      return person.getSocialSecurityNumber();<br style="font-family: Courier New;" />    }<br style="font-family: Courier New;" />  }</pre>
</blockquote>
<p>To create an indexed list for an empty ArrayList&lt;Person&gt; with an index on a person&#8217;s social security number you can then easily use the Class UniqueIndexedList:</p>
<blockquote>
<pre>UnqiueIndexedList&lt;Person, String&gt; myList =
  UnqiueIndexedList.create(getSsnrForPerson);</pre>
</blockquote>
<p>Of course all the usual methods of the List&lt;Person&gt; interface can be used as usual:</p>
<blockquote>
<pre>myList.add(somePerson);
myList.add(anotherPerson);
myList.get(i);
myList.iterator();</pre>
</blockquote>
<p>Additionaly there are  methods to access objects by index:<br style="font-family: Courier New;" /></p>
<blockquote>
<pre>boolean personIsInList = myList.containsByIndex("34897634853");</pre>
<pre>Person p = myList.getByIndex("34897634853");</pre>
</blockquote>
<p>The code for the list implementation currently resides here:</p>
<ul>
<li><a id="neqh" title="http://code.google.com/p/data-integrity-check/source/browse/trunk/src/main/java/de/fmaul/common/collect/IndexedList.java" href="http://code.google.com/p/data-integrity-check/source/browse/trunk/src/main/java/de/fmaul/common/collect/IndexedList.java">IndexedList.java</a></li>
<li><a id="uk2m" title="http://code.google.com/p/data-integrity-check/source/browse/trunk/src/main/java/de/fmaul/common/collect/UniqueIndexedList.java" href="http://code.google.com/p/data-integrity-check/source/browse/trunk/src/main/java/de/fmaul/common/collect/UniqueIndexedList.java">UniqueIndexedList.java</a></li>
</ul>
<p>It is basically a hybrid of a List and a special index-Map and works well so far. I am sure that finding objects in list for a given attribute is a very common usecase. Why hasn&#8217;t anyone solved this yet? Are there (better) alternatives that I&#8217;ve missed?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techbits.de/2009/07/18/indexedlist-a-hybrid-of-a-java-list-and-a-map/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PhpWebChecksum to be released soon</title>
		<link>http://www.techbits.de/2006/01/11/phpwebchecksum-to-be-released-soon/</link>
		<comments>http://www.techbits.de/2006/01/11/phpwebchecksum-to-be-released-soon/#comments</comments>
		<pubDate>Wed, 11 Jan 2006 19:34:15 +0000</pubDate>
		<dc:creator>florian</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[phpwebchecksum]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sourceforge]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.techbits.de/2006/01/11/phpwebchecksum-to-be-released-soon/</guid>
		<description><![CDATA[
The first version of my php script to monitor changes in your website will be released soon. I already set up a sourceforge account for PhpWebChecksum which will be mainly used for bugtracking, and maybe source code management (CVS) and file storage for releases for now. The projects homepage will be hosted on techbits.de under [...]]]></description>
			<content:encoded><![CDATA[<p>
The first version of my php script to monitor changes in your website will be released soon. I already set up a <a href="http://sourceforge.net/projects/phpwebchecksum">sourceforge account for PhpWebChecksum</a> which will be mainly used for bugtracking, and maybe source code management (CVS) and file storage for releases for now. The projects homepage will be hosted on techbits.de under <a href="http://www.techbits.de/projects/phpwebchecksum/">/projects/phpwebchecksum</a> which is already available as well. At this point I have to make sure I can use <a href="http://keithdevens.com/software/phpxml">Keith Devens&#8217; PHP XML Library</a> which I included in my php script and figure out how I&#8217;ll solve the pass-by-reference issue when switching between PHP4 und PHP5.
</p>
<p>Here is another teaser screenshot of the main form with header, footer and some design improvements:
</p>
<p><a class="imagelink" href="http://www.techbits.de/wp-content/uploads/2006/01/phpwebchecksum1.png" title="main form with some design improvements"><img id="image12" src="http://www.techbits.de/wp-content/uploads/2006/01/phpwebchecksum1.thumbnail.png" alt="main form with some design improvements" height="57" width="128" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techbits.de/2006/01/11/phpwebchecksum-to-be-released-soon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
