On Thursday, 26 May 2016 at 21:13:14 UTC, Era Scarecrow wrote:
To do what I want currently it's something like...
enum Size = 1024, Other = 128;
Data[Size][Other] staticarray; //stack allocation
Data[][] sliced = staticarray[];
scan(sliced, condition);
void scan(ref Data[][] data,
On Friday, 27 May 2016 at 09:18:47 UTC, Marc Schütz wrote:
You can do that with arrays, too, without causing allocations:
assert(slice.length < static_array.length);
slice = slice.ptr[0 .. slice.length+1];
Of course that's unsafe, but your pointer magic certainly is,
too.
Initial
On Thursday, 26 May 2016 at 22:47:02 UTC, Era Scarecrow wrote:
On Thursday, 26 May 2016 at 22:15:42 UTC, ag0aep6g wrote:
Sorry, I'm still lost. Why can't you do whatever you're doing
in opOpAssign directly there, or in a free function? Does the
pseudo-array contain any additional data? Would a
On Thursday, 26 May 2016 at 22:15:42 UTC, ag0aep6g wrote:
On 05/26/2016 11:13 PM, Era Scarecrow wrote:
void scan(ref Data[][] data, Condition cond) {
foreach(i; ...) {
if (cond)
data[i] ~= ...
}
}
Sorry, I'm still lost. Why can't you do whatever you're doing
On 05/26/2016 11:13 PM, Era Scarecrow wrote:
By adding a struct overload for opOpAssign I can shrink it all down
to this, and avoid lengths entirely... As such internally the length
starts at 0, and checks are in place to ensure the bounds are never
exceeded.
void scan(ref Data[][] data,
On Thursday, 26 May 2016 at 12:33:31 UTC, Adam D. Ruppe wrote:
On Thursday, 26 May 2016 at 12:30:30 UTC, Alex Parrill wrote:
The line "not having to make another array to keep track of
lengths and then shorten them" is fairly vague. "Shortening"
an array via slicing is basically free (it's
On Thursday, 26 May 2016 at 11:47:13 UTC, ag0aep6g wrote:
I don't follow. Why can't you use a built-in array? What can
you do with the stand-in that you can't do with the array
itself?
I can do the job with the built-in arrays, however the need for
another temporary array to keep track of
On Thursday, 26 May 2016 at 07:51:46 UTC, Era Scarecrow wrote:
If the ptr is at offset 0, we declare it first, otherwise
second, simple... Except this fails since "no property
'offsetof' for type 'void*'". SO... I make a template to test
for it instead.
Built-in arrays are kinda magical
On Thursday, 26 May 2016 at 12:30:30 UTC, Alex Parrill wrote:
The line "not having to make another array to keep track of
lengths and then shorten them" is fairly vague. "Shortening" an
array via slicing is basically free (it's just some integer
arithmetic), but I'm not sure if that's what you
On Thursday, 26 May 2016 at 07:51:46 UTC, Era Scarecrow wrote:
...
This smells like an XY problem [0]. Why exactly do you need the
internal layout of the array structure?
The line "not having to make another array to keep track of
lengths and then shorten them" is fairly vague.
On 05/26/2016 09:51 AM, Era Scarecrow wrote:
So I'm experimenting and want to override how arrays are managed for a
short duration, this is for optimization of not having to make another
array to keep track of lengths and then shorten them when i can in fact
just manage it myself *very*
On Thursday, 26 May 2016 at 09:16:48 UTC, Kagamin wrote:
try this:
struct X
{
byte[] data;
alias data this;
}
This doesn't help me with what I want, and effectively does
nothing as far as I can tell. Although testing is showing
managing the pointer & length directly is a
try this:
struct X
{
byte[] data;
alias data this;
}
So I'm experimenting and want to override how arrays are managed
for a short duration, this is for optimization of not having to
make another array to keep track of lengths and then shorten them
when i can in fact just manage it myself *very* briefly.
So, I need to make sure the structure
14 matches
Mail list logo