<?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>Code Comments &#187; Collections</title>
	<atom:link href="http://code.hammerpig.com/category/collections/feed" rel="self" type="application/rss+xml" />
	<link>http://code.hammerpig.com</link>
	<description>Tips and short tutorials on various programming technologies</description>
	<lastBuildDate>Fri, 23 Dec 2011 23:09:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating a Reverse Sequence of Numbers in Python</title>
		<link>http://code.hammerpig.com/creating-reverse-sequence-numbers-python.html</link>
		<comments>http://code.hammerpig.com/creating-reverse-sequence-numbers-python.html#comments</comments>
		<pubDate>Wed, 14 Jan 2009 15:15:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Collections]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=529</guid>
		<description><![CDATA[Let&#8217;s say you want to create a sequence of numbers in reverse order (for example, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1). I tried to do this with the range function, but I couldn&#8217;t find a way to do it. But Python has a built-in function called reversed that allows you to [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/creating-reverse-sequence-numbers-python.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cast a List from One Type to Another in Python</title>
		<link>http://code.hammerpig.com/cast-a-list-from-one-type-to-another-in-python.html</link>
		<comments>http://code.hammerpig.com/cast-a-list-from-one-type-to-another-in-python.html#comments</comments>
		<pubDate>Sat, 27 Dec 2008 07:23:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Collections]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=468</guid>
		<description><![CDATA[One of the key properties of Python is that it is a weakly typed language. In contract to strongly typed languages such as Java, you don&#8217;t have to define the class of an object when you instantiate it. This offers much flexibility. But sometimes you want to be able to define precisely what class of [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/cast-a-list-from-one-type-to-another-in-python.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find the Difference Between Two Arrays in Java</title>
		<link>http://code.hammerpig.com/find-the-difference-between-two-arrays-in-java.html</link>
		<comments>http://code.hammerpig.com/find-the-difference-between-two-arrays-in-java.html#comments</comments>
		<pubDate>Thu, 18 Dec 2008 04:04:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Collections]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=277</guid>
		<description><![CDATA[Please refer to this post for explanation of how to do this using Lists in Java. If you wanted to do the same thing with arrays, you would simply need to convert the arrays to ArrayLists before you find the difference.
]]></description>
		<wfw:commentRss>http://code.hammerpig.com/find-the-difference-between-two-arrays-in-java.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force Collections to Accept Only One Data Type in Java</title>
		<link>http://code.hammerpig.com/force-collections-to-accept-only-one-data-type-in-java.html</link>
		<comments>http://code.hammerpig.com/force-collections-to-accept-only-one-data-type-in-java.html#comments</comments>
		<pubDate>Sun, 14 Dec 2008 07:56:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Collections]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=404</guid>
		<description><![CDATA[Collections, such as ArrayList and Set, in Java used to be able to contain any class. So you could implement the following code without a problem.

ArrayList oldWay = new ArrayList&#40;&#41;;
oldWay.Add&#40;&#34;xyz&#34;&#41;;
oldWay.Add&#40;456&#41;;
oldWay.Add&#40;new CustomWhatever&#40;&#41;&#41;;

But sometimes this flexibility caused problems because you might want to limit what could be contained in that list (for example, limit it to String [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/force-collections-to-accept-only-one-data-type-in-java.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force Collections to Accept Only One Class in C#</title>
		<link>http://code.hammerpig.com/force-collections-to-accept-only-one-class-in-c.html</link>
		<comments>http://code.hammerpig.com/force-collections-to-accept-only-one-class-in-c.html#comments</comments>
		<pubDate>Tue, 09 Dec 2008 04:55:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=406</guid>
		<description><![CDATA[Collections, such as List and ArrayList, in C# used to be able to contain any class. So you could implement the following code without a problem.

ArrayList oldWay = new ArrayList&#40;&#41;;
oldWay.Add&#40;&#34;abc&#34;&#41;;
oldWay.Add&#40;123&#41;;
oldWay.Add&#40;new CustomWhatever&#40;&#41;&#41;;

But sometimes this flexibility caused problems because you might want to limit what could be contained in that list (for example, limit it to string [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/force-collections-to-accept-only-one-class-in-c.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Example of Implementing IEnumerable and IEnumerator in C#</title>
		<link>http://code.hammerpig.com/example-of-implementing-ienumerable-and-ienumerator-in-c.html</link>
		<comments>http://code.hammerpig.com/example-of-implementing-ienumerable-and-ienumerator-in-c.html#comments</comments>
		<pubDate>Tue, 09 Dec 2008 04:32:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=287</guid>
		<description><![CDATA[In the .NET Framework, there are two interfaces designed to allow you to iterate easily over collections of objects as you would typically do in a for loop. Many classes in the .NET Framework have implemented these interfaces and do their work behind the scenes so you don&#8217;t have to worry about how it is [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/example-of-implementing-ienumerable-and-ienumerator-in-c.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find an Object in an ArrayList with Java</title>
		<link>http://code.hammerpig.com/find-an-object-in-an-arraylist-with-java.html</link>
		<comments>http://code.hammerpig.com/find-an-object-in-an-arraylist-with-java.html#comments</comments>
		<pubDate>Tue, 02 Dec 2008 20:36:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Collections]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=358</guid>
		<description><![CDATA[Let&#8217;s say you have an ArrayList in Java.

ArrayList&#60;String&#62; a = new ArrayList&#60;String&#62;&#40;&#41;;
a.add&#40;&#34;abc&#34;&#41;;
a.add&#40;&#34;def&#34;&#41;;
a.add&#40;&#34;ghi&#34;&#41;;

Now let&#8217;s say you wanted to grab the &#8220;def&#8221; object out of it. You could do this in the following way:

String b = a.get&#40;a.indexOf&#40;&#34;def&#34;&#41;&#41;;

You can only retrieve an object from an ArrayList by its index. So a simple workaround is first to find the [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/find-an-object-in-an-arraylist-with-java.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Find the Difference Between Two Lists with Python</title>
		<link>http://code.hammerpig.com/find-the-difference-between-two-lists-with-python.html</link>
		<comments>http://code.hammerpig.com/find-the-difference-between-two-lists-with-python.html#comments</comments>
		<pubDate>Sun, 30 Nov 2008 06:42:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Collections]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=353</guid>
		<description><![CDATA[Let&#8217;s say you have two lists in Python that have a lot of overlap between them.

a = &#91;&#34;abc&#34;,&#34;def&#34;,&#34;ghi&#34;&#93;
b = &#91;&#34;def&#34;,&#34;ghi&#34;,&#34;jkl&#34;&#93;

Now let&#8217;s say you want to determine what is in b that is not in a. In set theory, you would refer to this as the set-theoretic difference of b in a. The following simple code [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/find-the-difference-between-two-lists-with-python.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Find the Difference Between Two Lists in Java</title>
		<link>http://code.hammerpig.com/find-the-difference-between-two-lists-in-java.html</link>
		<comments>http://code.hammerpig.com/find-the-difference-between-two-lists-in-java.html#comments</comments>
		<pubDate>Sun, 30 Nov 2008 06:21:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Collections]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=349</guid>
		<description><![CDATA[Let&#8217;s say you have two lists in Java that have a lot of overlap between them.

ArrayList a = new ArrayList&#40;&#41;;
a.add&#40;&#34;abc&#34;&#41;;
a.add&#40;&#34;def&#34;&#41;;
a.add&#40;&#34;ghi&#34;&#41;;
&#160;
ArrayList b = new ArrayList&#40;&#41;;
b.add&#40;&#34;def&#34;&#41;;
b.add&#40;&#34;ghi&#34;&#41;;
b.add&#40;&#34;jkl&#34;&#41;;

Now let&#8217;s say you want to determine what is in b that is not in a. In set theory, you would refer to this as the set-theoretic difference of b in a. [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/find-the-difference-between-two-lists-in-java.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Add an Item to an Array in Java</title>
		<link>http://code.hammerpig.com/add-an-item-to-an-array-in-java.html</link>
		<comments>http://code.hammerpig.com/add-an-item-to-an-array-in-java.html#comments</comments>
		<pubDate>Fri, 21 Nov 2008 23:54:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Collections]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=253</guid>
		<description><![CDATA[If you haven&#8217;t read this post that talks about the differences between arrays and ArrayLists, that would be a good first step. Typically you would use an ArrayList rather than an array if you want to be able to add and remove objects. However, if you would rather (or are required to) use arrays, this [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/add-an-item-to-an-array-in-java.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

