www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - columnar struct storage template

reply BCS <ao pathlink.com> writes:
If you have an array of structs that is primarily accessed by columns (the 
same member in each item) rather than by rows (all members in a given item) 
it can be faster to store the members each in there own array. The Columns 
template automates this for POD struct types.

http://www.dsource.org/projects/scrapple/browser/trunk/columns/columns.d
Dec 13 2008
parent reply Nestor <nestorperez2016 yopmail.com> writes:
On Saturday, 13 December 2008 at 21:13:52 UTC, BCS wrote:
 If you have an array of structs that is primarily accessed by 
 columns (the same member in each item) rather than by rows (all 
 members in a given item) it can be faster to store the members 
 each in there own array. The Columns template automates this 
 for POD struct types.

 http://www.dsource.org/projects/scrapple/browser/trunk/columns/columns.d
This no longer compiles on recent versions of DMD :(
Jan 29 2017
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Sunday, 29 January 2017 at 13:09:18 UTC, Nestor wrote:
 This no longer compiles on recent versions of DMD :(
Trivial fix though, it just needs to say "\n" instead of plain \n (it is missing quotes, D used to allow that for whatever stupid reason and has since been fixed). Actually, tbh, I'm surprised it isn't a bigger fix needed given that that post is from 9 years ago!
Jan 29 2017
parent reply Nestor <nestorperez2016 yopmail.com> writes:
On Sunday, 29 January 2017 at 13:45:12 UTC, Adam D. Ruppe wrote:
 On Sunday, 29 January 2017 at 13:09:18 UTC, Nestor wrote:
 This no longer compiles on recent versions of DMD :(
Trivial fix though, it just needs to say "\n" instead of plain \n (it is missing quotes, D used to allow that for whatever stupid reason and has since been fixed). Actually, tbh, I'm surprised it isn't a bigger fix needed given that that post is from 9 years ago!
Where is it missing the quotes? I tried fixing it like this, but it still doesn't compile: "(){return members["~j.stringof~"];}\"\n\""
Jan 29 2017
parent reply ezneh <petitv.isat gmail.com> writes:
On Sunday, 29 January 2017 at 14:00:37 UTC, Nestor wrote:
 On Sunday, 29 January 2017 at 13:45:12 UTC, Adam D. Ruppe wrote:
 On Sunday, 29 January 2017 at 13:09:18 UTC, Nestor wrote:
 This no longer compiles on recent versions of DMD :(
Trivial fix though, it just needs to say "\n" instead of plain \n (it is missing quotes, D used to allow that for whatever stupid reason and has since been fixed). Actually, tbh, I'm surprised it isn't a bigger fix needed given that that post is from 9 years ago!
Where is it missing the quotes? I tried fixing it like this, but it still doesn't compile: "(){return members["~j.stringof~"];}\"\n\""
Here : foreach(uint u; FooCol.j) writef("%s ", u); writef(\n);
Jan 29 2017
parent Nestor <nestorperez2016 yopmail.com> writes:
On Sunday, 29 January 2017 at 14:16:37 UTC, ezneh wrote:
 Here :

  foreach(uint  u; FooCol.j) writef("%s ", u); writef(\n);
I see, but apparently this isn't the only issue. I replaced the whole unittest with this, and it still doesn't compile: import std.stdio; void main() { struct MyStruct { uint i; float j; } MyStruct data; Columns!(MyStruct) MyCols; } Problems this time were in the AfterLast function, which I modified like this: string AfterLast(string s, char c) { foreach_reverse(int i, char d; s) if(c==d) return s[i+1..$]; return s; } However there are still some errors which I don´t know how to fix: columns1.d(45): Error: cannot implicitly convert expression (this) of type Columns!(MyStruct) to Columns!(MyStruct)* columns1.d(63): Error: template instance columns1.Columns!(MyStruct) error instantiating Line 63 is the declaration of MyCols, and line 45 would be thisÑ At opIndex(uint i) { return At(this,i); }
Jan 29 2017