{"id":928,"date":"2004-01-09T15:26:00","date_gmt":"2004-01-09T21:26:00","guid":{"rendered":"http:\/\/www.lordandrei.com\/blog\/?p=928"},"modified":"2004-01-09T15:26:00","modified_gmt":"2004-01-09T21:26:00","slug":"a-week-without-lj","status":"publish","type":"post","link":"http:\/\/www.lordandrei.com\/blog\/2004\/01\/09\/a-week-without-lj\/","title":{"rendered":"A week without LJ"},"content":{"rendered":"<p>I&#8217;ve been off LJ for a week. Both reading and writing. Not for any reason beyond, I&#8217;ve been a little too busy.<\/p>\n<p>Last week was New Years Eve and this week saw me stepping in for a sick clergy member to do mass on short notice and also teaching the first part of my class on Hebrew. At the end of this week I am assisting with an initiation ritual for my church.<\/p>\n<p>The reason I&#8217;m posting today and getting myself back on LJ is that I actually have something I want to babble about. I looked around the office and since I&#8217;m the only one here there was no one I could talk to about what I did.<\/p>\n<p>When a performer performs or an artist creates you can show it to anyone and they can go &#8216;oooh&#8217; or &#8216;ugh&#8217;&#8230; When you code and accomplish something, you just don&#8217;t have the same audience.<\/p>\n<p>The below is some of what I do in a day and the feeling of accomplishment. Most of what&#8217;s here will probably make next to zero sense to my average reader. But I will confide that the accomplishment does give me the reaction of seeing my team make a touchdown in an important game.<\/p>\n<p>And to think, my coworker said that I needed some code to get passionate about. He has no idea \ud83d\ude09<\/p>\n<p>If you are curious about this and want me to further explain or would like to learn more about this, feel free to comment in this journal and I&#8217;ll answer questions as best I can. I will also attempt not to betray any NDA&#8217;s about what I&#8217;m actually working on \ud83d\ude42<br \/>\n<!--more So what did I do. (Warning tech)--><br \/>\n<a href=\"http:\/\/www.livejournal.com\/community\/macosxdev\/47015.html\">Sort of cross posted to <\/a><a href=\"http:\/\/macosxdev.livejournal.com\/\" class=\"lj-user\">macosxdev<\/a> journals.<\/p>\n<p>A precursor to this is that I am entirely self-taught. My experience in the industry over the last 10 years has kept me from  the minutia of data-structures classes that I would have acquired had I actually been a CS major. Most of the stuff I would have gotten out of these classes  comes from self-innovation rather than, &#8220;oh yeah, we learned that. Only die-hard unix&#8217;y geeks ever really deal with this.&#8221; Granted, if this is something really cool, I&#8217;d like to mark it patent pending right here and now and leave it at that. Personally, I think this may just be something others have done and I&#8217;ve gotten a warm fuzzy at least figuring it out on my own.<\/p>\n<p>I am currently trying to wrap a set of C libraries and structures into an Obj-C framework. The data itself comes in a series of linked nodes:<\/p>\n<style type=\"text\/css\"><!--.comment{\tcolor: red;\tfont-family: courier;\tfont-size: 9pt;}.code{\tfont-family: courier;\tfont-size: 9pt;}--><\/style>\n<p><font class=\"code\">typedef struct generic_node<\/font><\/p>\n<table class=\"code\" border=\"0\" align=\"left\">\n<tr>\n<td>int<\/td>\n<td>node-type<\/td>\n<td class=\"comment\">\/\/ which subnode type it is<\/td>\n<\/tr>\n<tr>\n<td>char *<\/td>\n<td>name<\/td>\n<td class=\"comment\">\/\/ name of node<\/td>\n<\/tr>\n<tr>\n<td>generic_node *<\/td>\n<td>child_head<\/td>\n<td class=\"comment\">\/\/ first child of this node<\/td>\n<\/tr>\n<tr>\n<td>generic_node *<\/td>\n<td>last_child<\/td>\n<td class=\"comment\">\/\/ last child of node<\/td>\n<\/tr>\n<tr>\n<td>generic_node *<\/td>\n<td>parent<\/td>\n<td class=\"comment\">\/\/ node that this was a child of<\/td>\n<\/tr>\n<tr>\n<td>generic_node *<\/td>\n<td>next_child<\/td>\n<td class=\"comment\">\/\/ next sibling along the chain<\/td>\n<\/tr>\n<tr>\n<td>generic_node *<\/td>\n<td>last_child<\/td>\n<td class=\"comment\">\/\/ last sibling on the chain<\/td>\n<\/tr>\n<tr>\n<td>foo struct<\/td>\n<td>bar members&nbsp;&nbsp;<\/td>\n<td class=\"comment\">\/\/ depends on the int for node-type<\/td>\n<\/tr>\n<\/table>\n<p>Now for every node, I want to create an Obj-C object.  Unfortunately, since the list is linked backwards and forwards, I have to track every object I make. I don&#8217;t want to make a new one for a node&#8217;s <font class=\"code\">prev<\/font> if it has already been made. I just want to link to the previously made object.<\/p>\n<p>So, I came up with the idea of a hash table that is divided into the hard hex address of the original data for the node as a string. And the data for that key being the object made for it. The idea would be that I would make a node, add the child info by recursively walking the child list, and then add the next info by walking the next chain. If I made a hash lookup of each object as it was created, when I got to a <font class=\"code\">prev<\/font> it would be by way of an object&#8217;s <font class=\"code\">next<\/font> that was already on my list.<\/p>\n<p>I made the new node object, I made the <font class=\"code\">child<\/font> check (and set the new node&#8217;s <font class=\"code\">child<\/font> ), I made the <font class=\"code\">next<\/font> check (and set the new node&#8217;s <font class=\"code\">next<\/font>), I did the <font class=\"code\">prev<\/font> lookup (set it if found), and of course I added my new object onto the hash list. And sure enough&#8230;<\/p>\n<p>It utterly failed.<\/p>\n<p>Now, there are two ways to debug a concept that should have worked. I of course did them in the wrong order. In the order I researched my problem&#8230;<\/p>\n<ol>\n<li>Give lots of debug data to look over what you did.<\/li>\n<li>Close your eyes and contemplate what you did in code.<\/li>\n<\/ol>\n<p>The failure was that none of the nodes were on my hash list at the time they were being looked for. Sometimes very late in the list. <\/p>\n<p>And then I went to step 2.<\/p>\n<p>I realized that once the new node object is made, regardless of whether I&#8217;ve set it&#8217;s <font class=\"code\">child<\/font> or <font class=\"code\">next<\/font> or what have you, it can now be put on the hash table. I moved the 5 lines of code up to right after the object creation but before the child lookup and&#8230;<br \/>\n<font class=\"code\"><br \/>\nNo prev for item  [388650]<br \/>\nDictionary has 31 hashes.<br \/>\nDictionary has 32 hashes.<br \/>\nDictionary has 33 hashes.<br \/>\nNo prev for item  [3889a0]<br \/>\nFound previous addr [388890] in table for item [388960]<br \/>\nFound previous addr [388710] in table for item [388890]<br \/>\nFound previous addr [3885d0] in table for item [388710]<\/font><\/p>\n<p>As a side note, <font class=\"comment\">\/\/ I really love .css<\/font><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-928\" class=\"share-facebook sd-button share-icon no-text\" href=\"http:\/\/www.lordandrei.com\/blog\/2004\/01\/09\/a-week-without-lj\/?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Facebook (Opens in new window)<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-928\" class=\"share-twitter sd-button share-icon no-text\" href=\"http:\/\/www.lordandrei.com\/blog\/2004\/01\/09\/a-week-without-lj\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Twitter (Opens in new window)<\/span><\/a><\/li><li class=\"share-pinterest\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-pinterest-928\" class=\"share-pinterest sd-button share-icon no-text\" href=\"http:\/\/www.lordandrei.com\/blog\/2004\/01\/09\/a-week-without-lj\/?share=pinterest\" target=\"_blank\" title=\"Click to share on Pinterest\" ><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Pinterest (Opens in new window)<\/span><\/a><\/li><li class=\"share-tumblr\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-tumblr sd-button share-icon no-text\" href=\"http:\/\/www.lordandrei.com\/blog\/2004\/01\/09\/a-week-without-lj\/?share=tumblr\" target=\"_blank\" title=\"Click to share on Tumblr\" ><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Tumblr (Opens in new window)<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been off LJ for a week. Both reading and writing. Not for any reason beyond, I&#8217;ve been a little too busy. Last week was New Years Eve and this week saw me stepping in for a sick clergy member to do mass on short notice and also teaching the first part of my class [&hellip;]<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-928\" class=\"share-facebook sd-button share-icon no-text\" href=\"http:\/\/www.lordandrei.com\/blog\/2004\/01\/09\/a-week-without-lj\/?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Facebook (Opens in new window)<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-928\" class=\"share-twitter sd-button share-icon no-text\" href=\"http:\/\/www.lordandrei.com\/blog\/2004\/01\/09\/a-week-without-lj\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Twitter (Opens in new window)<\/span><\/a><\/li><li class=\"share-pinterest\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-pinterest-928\" class=\"share-pinterest sd-button share-icon no-text\" href=\"http:\/\/www.lordandrei.com\/blog\/2004\/01\/09\/a-week-without-lj\/?share=pinterest\" target=\"_blank\" title=\"Click to share on Pinterest\" ><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Pinterest (Opens in new window)<\/span><\/a><\/li><li class=\"share-tumblr\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-tumblr sd-button share-icon no-text\" href=\"http:\/\/www.lordandrei.com\/blog\/2004\/01\/09\/a-week-without-lj\/?share=tumblr\" target=\"_blank\" title=\"Click to share on Tumblr\" ><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Tumblr (Opens in new window)<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[1],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1X6ba-eY","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.lordandrei.com\/blog\/wp-json\/wp\/v2\/posts\/928"}],"collection":[{"href":"http:\/\/www.lordandrei.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.lordandrei.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.lordandrei.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.lordandrei.com\/blog\/wp-json\/wp\/v2\/comments?post=928"}],"version-history":[{"count":0,"href":"http:\/\/www.lordandrei.com\/blog\/wp-json\/wp\/v2\/posts\/928\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.lordandrei.com\/blog\/wp-json\/wp\/v2\/media?parent=928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.lordandrei.com\/blog\/wp-json\/wp\/v2\/categories?post=928"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.lordandrei.com\/blog\/wp-json\/wp\/v2\/tags?post=928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}