
{"id":282,"date":"2015-12-08T22:59:11","date_gmt":"2015-12-08T22:59:11","guid":{"rendered":"http:\/\/timallen.name\/?p=282"},"modified":"2016-01-07T16:07:28","modified_gmt":"2016-01-07T16:07:28","slug":"fun-differences-betwixt-java-and-c-containers","status":"publish","type":"post","link":"https:\/\/timallen.name\/index.php\/2015\/12\/08\/fun-differences-betwixt-java-and-c-containers\/","title":{"rendered":"fun differences betwixt Java and C++ containers"},"content":{"rendered":"<p>&#8230;and for my next rant I wax poetic about the joys of writing code in the morning using C++ containers and in the afternoon switching to Java!<\/p>\n<p>So I&#8217;ve got me an array of, I dunno uint32_t&#8217;s, and I&#8217;m just happy as a clam with my fun member functions and I&#8217;m callin&#8217; &#8217;em and I&#8217;m doing all sorts of cleverness, and then it comes time to do something with my amusingly arranged array. I need to call something that takes a pointer to an array of uint32_t&#8217; or better yet I need to manipulate my fancy C++ array very quickly. No problem, this is still C isn&#8217;t it, bloated and strange but I can still get a pointer, why yes I can. A quick call to array::data() and I get me a pointer to an array of uint32_t&#8217;s&#8230;but not just any array of uint32_t&#8217;s _the_ array, not a copy (that the cpu had to do a shit load of work to make) the real thing&#8230; and I can do what I want with this array, may not be wise but I&#8217;m good to go!<\/p>\n<p>&#8230;and later that day I&#8217;m writing some Java; and I got me a SortedSet&#8230; clever&#8230; arrange&#8230; member functions&#8230; But now I gotta call some Android crap and it wants an array because it&#8217;s going to display it somewhere. So I go to the documentation and I read, &#8220;toArray() Returns an array containing all elements contained in this set.&#8221; and I&#8217;m having flashbacks to this morning and I think jammin! I&#8217;ll just use these cutesy member functions to cleverly arrange my set and then I&#8217;ll call this refresh (update whatever) method and I already passed Android a reference to the underlying array and viol-la! &#8230;and it doesn&#8217;t bloody work. Well, it works the first time but I make my member calls on the set and I call refresh and I get the same display I got last time. So I reread the docs, it says, &#8220;toArray() Returns an array containing all elements contained in this set,&#8221; so what&#8217;s the problem&#8230; wait for it&#8230; Returns <strong>an<\/strong> array containing all elements contained in this set not <strong>the<\/strong> array. Effing Java decided to copy the whole bloody thing to a new array and then has the temerity to hand me a reference to this useless (and CPU intensive) pile of crap.  Arrrgghh, I hate Java. Yeah, yeah, yeah, copy on write whatever, memset this pal!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8230;and for my next rant I wax poetic about the joys of writing code in the morning using C++ containers and in the afternoon switching to Java! So I&#8217;ve got me an array of, I dunno uint32_t&#8217;s, and I&#8217;m just happy as a clam with my fun member functions and I&#8217;m callin&#8217; &#8217;em and I&#8217;m &hellip; <a href=\"https:\/\/timallen.name\/index.php\/2015\/12\/08\/fun-differences-betwixt-java-and-c-containers\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">fun differences betwixt Java and C++ containers<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-282","post","type-post","status-publish","format-standard","hentry","category-general-programming"],"_links":{"self":[{"href":"https:\/\/timallen.name\/index.php\/wp-json\/wp\/v2\/posts\/282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/timallen.name\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/timallen.name\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/timallen.name\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/timallen.name\/index.php\/wp-json\/wp\/v2\/comments?post=282"}],"version-history":[{"count":4,"href":"https:\/\/timallen.name\/index.php\/wp-json\/wp\/v2\/posts\/282\/revisions"}],"predecessor-version":[{"id":286,"href":"https:\/\/timallen.name\/index.php\/wp-json\/wp\/v2\/posts\/282\/revisions\/286"}],"wp:attachment":[{"href":"https:\/\/timallen.name\/index.php\/wp-json\/wp\/v2\/media?parent=282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/timallen.name\/index.php\/wp-json\/wp\/v2\/categories?post=282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/timallen.name\/index.php\/wp-json\/wp\/v2\/tags?post=282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}