I found myself doing BFS over a very large graph space and with vertices that carry a lot of information. My for this solution in C++ was to use bitsets to store the information in a vertex. I found no documentation of bitsets for Pico or Lua, so I thought of something I call a "nibbleset." A nibbleset is a metatable that holds numbers, and each nibble of the set of numbers can be accessed.
nibbleset = {} --Set nibble at index i to a value v: function nibbleset.set(a,i,v) if i/8 > #a then return end local n = ceil(i/8) local s = tostr(a[n],1) local tr = "0x" i-=1 i%=8 i+=1 if(i>4) i+=1 for j=1,9 do if j==i then tr..=v else tr..=s[j+2] end end a[n]=tonum(tr) end --Set nibble at index i to zero: function nibbleset.reset(a,i) if i/8 > #a then return end local n = ceil(i/8) [ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=151989#p) |