{"id":4573,"date":"2014-03-30T13:41:46","date_gmt":"2014-03-30T13:41:46","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/keeping-track-of-boolean-data-collection-of-common-programming-errors\/"},"modified":"2014-03-30T13:41:46","modified_gmt":"2014-03-30T13:41:46","slug":"keeping-track-of-boolean-data-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/keeping-track-of-boolean-data-collection-of-common-programming-errors\/","title":{"rendered":"Keeping track of boolean data-Collection of common programming errors"},"content":{"rendered":"<p>I need to keep track of n samples. The information I am keeping track of is of boolean type, i.e. something is true or false. As soon as I am on sample n+1, i basically want to ignore the oldest sample and record information about the newest one.<\/p>\n<p>So say I keep track of samples, I may have something like<\/p>\n<p>OLDEST 0 0 1 1 0 NEWEST<\/p>\n<p>If the next sample is 1, this will become<\/p>\n<p>OLDEST 0 1 1 0 1 NEWEST<\/p>\n<p>if the next one is 0, this will become&#8230;<\/p>\n<p>OLDEST 1 1 0 1 0 NEWEST<\/p>\n<p>So what is the best way to implement this in terms of simplicity and memory?<\/p>\n<p>Some ideas I had:<\/p>\n<blockquote>\n<blockquote>\n<p>Vector of bool (this would require shifting elements so seems expensive) Storing it as bits&#8230;and using bit shifting (memorywise &#8211;cheap? but is there a limit on the number of samples?) Linked lists? (might be an overkill for the task)<\/p>\n<\/blockquote>\n<\/blockquote>\n<p>Thanks for the ideas and suggestions \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I need to keep track of n samples. The information I am keeping track of is of boolean type, i.e. something is true or false. As soon as I am on sample n+1, i basically want to ignore the oldest sample and record information about the newest one. So say I keep track of samples, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4573","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4573"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4573\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}