Thread overview |
---|
December 13, 2008 columnar struct storage template | ||||
---|---|---|---|---|
| ||||
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 |
January 29, 2017 Re: columnar struct storage template | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | 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 :(
|
January 29, 2017 Re: columnar struct storage template | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nestor | 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!
|
January 29, 2017 Re: columnar struct storage template | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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\"" |
January 29, 2017 Re: columnar struct storage template | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nestor | 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);
|
January 29, 2017 Re: columnar struct storage template | ||||
---|---|---|---|---|
| ||||
Posted in reply to ezneh | 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); }
|
Copyright © 1999-2021 by the D Language Foundation