{"id":109,"date":"2016-04-06T08:49:08","date_gmt":"2016-04-06T08:49:08","guid":{"rendered":"http:\/\/blog.qubekwest.com\/?p=109"},"modified":"2016-04-14T18:33:49","modified_gmt":"2016-04-14T18:33:49","slug":"data-structures-101","status":"publish","type":"post","link":"https:\/\/blog.qubekwest.com\/?p=109","title":{"rendered":"Data Structures 101"},"content":{"rendered":"<p>The revision of my world geography objects inspired a lot of other thought about how my world was going to work. \u00a0Specifically how I was going to represent or store the important parts of my world. \u00a0This in turn resulted in me digging in with a notebook and a pen and starting to try to figure out what I would need and how it would work.<\/p>\n<p>Once I had my basics in place on paper, I started making all of the changes needed to make them possible. \u00a0The first was to start making loads of additional data structures. \u00a0After all the talking about clusters, I needed to finish creating the class that represents them. \u00a0I had additional ideas about world features as an external structure, which led me to the idea of a BitList for storing large numbers of booleans efficiently without all the extra features or auto-sizing that Java&#8217;s BitSet provides. \u00a0The idea of having lots of features meant that keeping some sort of index to help know when to use them would be handy so the FeatureIndex and WorldVolume classes were born. \u00a0And so on&#8230;<\/p>\n<p>Next, my current design of IByteBufferSerializable was missing the idea of data structures that were variable size so I added that. \u00a0Also, I wanted to remove the serialization header from the size the objects reported for their serialized size. \u00a0As it turned out, this change to support variable sized objects meant it was actually helpful to have two different functions for reporting\u00a0the size of serialized objects. \u00a0One for the size of the data, and the other for the size of the data plus the header (because the header is a variable size too). \u00a0This makes slightly different hoops to jump through with serializing and deserializing, but in the end I believe them to be simpler hoops than remembering to include the header every time in my reported size. \u00a0Several of my data classes didn&#8217;t even support IByteBufferSerializable and others needed to be revised to match the new patterns.<\/p>\n<p>Finally, I wanted to add piles and piles of tests to ensure all the various parts of my fancy data structures worked the way I expected. \u00a0It would be a shame to be writing a world generator later on and to think something not appearing in the world correctly was because I screwed something up in the generator when in fact the error is in the way the data structure is holding the data. \u00a0You could literally waste hours or days trying to figure out where you went wrong all because you thought you got your data structures correct. \u00a0For that reason, similar to the massive numbers of math library tests, the data structure tests need to be extremely careful and complete. \u00a0If you can&#8217;t trust they are behaving properly when you are using them somewhere else, you don&#8217;t know where the actual problem you are encountering is coming from.<\/p>\n<p>Next I get to try to figure out how the heck things actually spatially line up in all these structures when considering the &#8220;real world&#8221; rendering of the places you will walk around. \u00a0My three dimensional chunk structure makes that frustratingly difficult to draw on paper, so it&#8217;s going to be a bit of mental gymnastics before I have the actual graphics pipeline working.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The revision of my world geography objects inspired a lot of other thought about how my world was going to work. \u00a0Specifically how I was going to represent or store the important parts of my world. \u00a0This in turn resulted in me digging in with a notebook and a pen and starting to try to &hellip; <a href=\"https:\/\/blog.qubekwest.com\/?p=109\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Data Structures 101<\/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":[3],"tags":[],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=109"}],"version-history":[{"count":4,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":114,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts\/109\/revisions\/114"}],"wp:attachment":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}