{"id":1005,"date":"2013-10-28T22:15:20","date_gmt":"2013-10-29T03:15:20","guid":{"rendered":"http:\/\/osric.com\/chris\/accidental-developer\/?p=1005"},"modified":"2013-10-28T22:18:25","modified_gmt":"2013-10-29T03:18:25","slug":"set-operations-in-coldfusion","status":"publish","type":"post","link":"https:\/\/osric.com\/chris\/accidental-developer\/2013\/10\/set-operations-in-coldfusion\/","title":{"rendered":"Set operations in ColdFusion"},"content":{"rendered":"<p>Today I needed to get all the elements in one list that were not members of a second list. That may ring a bell &#8212; it&#8217;s known as a set difference, or a relative complement.<\/p>\n<p>Although it would have been simple to loop through first the list and add only the elements not present in the second list to a new list, I thought I would look around to see if anyone had already implemented set operations in ColdFusion, e.g. on <a href=\"http:\/\/cflib.org\">cflib.org<\/a>. I was surprised that I didn&#8217;t find anything, so I decided to create my own, as much as an exercise as anything, and posted it to Bitbucket:<br \/>\n<a href=\"https:\/\/bitbucket.org\/cherdt\/arrayset\">arraySet: ColdFusion set operations<\/a><\/p>\n<p>I included the following operations:<\/p>\n<ul>\n<li>union<\/li>\n<li>intersection<\/li>\n<li>set difference<\/li>\n<li>subset<\/li>\n<li>equality<\/li>\n<li>size<\/li>\n<\/ul>\n<p>In the process, I experimented with <a href=\"http:\/\/mxunit.org\">MXUnit<\/a>, a unit testing suite for ColdFusion that integrates with Eclipse. (I am currently taking a Scala programming course that emphasizes Test-Driven Development, or TDD, so I thought I should try it in CF as well.)<\/p>\n<p>Since I was implementing sets using arrays as the underlying data structure, I also decided to use cfinterface to define a set interface, which arraySet implements. I had never used cfinterface before, and although <a href=\"http:\/\/www.bennadel.com\/blog\/816-Mom-Ben-Broke-My-CFInterface-.htm\">its usefulness has been questioned<\/a>, it seemed more appropriate than extending a base set class.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I needed to get all the elements in one list that were not members of a second list. That may ring a bell &#8212; it&#8217;s known as a set difference, or a relative complement. Although it would have been simple to loop through first the list and add only the elements not present in &hellip; <a href=\"https:\/\/osric.com\/chris\/accidental-developer\/2013\/10\/set-operations-in-coldfusion\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Set operations in ColdFusion<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[324,349,321,306,320,323,318,317,240,319,322],"class_list":["post-1005","post","type-post","status-publish","format-standard","hentry","category-coldfusion","tag-cfinterface","tag-coldfusion","tag-complement","tag-eclipse","tag-intersection","tag-mxunit","tag-set-operations","tag-sets","tag-tdd","tag-union","tag-unit-testing"],"_links":{"self":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/comments?post=1005"}],"version-history":[{"count":3,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1005\/revisions"}],"predecessor-version":[{"id":1009,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1005\/revisions\/1009"}],"wp:attachment":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/media?parent=1005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/categories?post=1005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/tags?post=1005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}