https://forum.dlang.org/post/rkxnfxsjvkffxufok...@forum.dlang.org
On Thursday, 1 January 2015 at 19:18:34 UTC, Nordlöw wrote:
Do we really need Append and Prepend (along with append and
prepend) here? Doesn't [cC]hain already fulfill the needs of a
lazy range in this case inplace of Append?
I
On Wednesday, 31 December 2014 at 00:36:36 UTC, Damian wrote:
Append and Prepend would be very useful additions to Phobos it's
quite surprising there not already there? In any case would love
to see some pull requests :)
Do we really need Append and Prepend (along with append and
prepend) here
On Friday, 26 December 2014 at 16:31:48 UTC, Nordlöw wrote:
On Friday, 26 December 2014 at 16:29:56 UTC, Nordlöw wrote:
See my update at
https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1602
which tries to merge all the ideas into one adapting algorithm
:)
Destroy!
BTW:
1. Is
On Saturday, 27 December 2014 at 07:34:43 UTC, Tobias Pankrath
wrote:
On Friday, 26 December 2014 at 16:31:48 UTC, Nordlöw wrote:
On Friday, 26 December 2014 at 16:29:56 UTC, Nordlöw wrote:
See my update at
https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1602
which tries to merge
On Friday, 26 December 2014 at 16:31:48 UTC, Nordlöw wrote:
On Friday, 26 December 2014 at 16:29:56 UTC, Nordlöw wrote:
See my update at
https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1602
which tries to merge all the ideas into one adapting algorithm
:)
Destroy!
BTW:
writ
On Friday, 26 December 2014 at 16:29:56 UTC, Nordlöw wrote:
See my update at
https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1602
which tries to merge all the ideas into one adapting algorithm
:)
Destroy!
BTW:
1. Is is relevant to extend `append` to data being a
non-Random-A
On Thursday, 18 December 2014 at 20:12:01 UTC, Tobias Pankrath
wrote:
You shouldn't use my code verbatim though. For example, you
should only use x.length, if x is of element type of data.
Otherwise if you have e.g. an array of array you'd get totally
wrong numbers.
What role does `x` play he
On Saturday, 20 December 2014 at 00:15:21 UTC, MarcelDuchamp
wrote:
You've forget the array of ref version. (append the address of
the first data)
What "array of ref" version? Sounds like it would be a different
data structure, which would be beyond the scope the topic.
And adding S to an arra
On Friday, 19 December 2014 at 14:41:07 UTC, Anonymous wrote:
What a big surprise. If you make an array of struct, each item
of your array has the length of the struct. structs a values.
If you want to append a struct to an array just append a
pointer to the struct:
--
struct arg{uint
On Saturday, 20 December 2014 at 00:44:54 UTC, zeljkog wrote:
If you wish run this just add:
struct S{
int n1, n2, n3, n4, n5 ...;
}
I wish. And I also wish you to get that to append in an array or
a in a list some ptr its not the same as appending structs,
particularly when the structs a
If you wish run this just add:
struct S{
int n1, n2, n3, n4, n5 ...;
}
On Saturday, 20 December 2014 at 00:15:21 UTC, MarcelDuchamp
wrote:
On Friday, 19 December 2014 at 23:24:13 UTC, zeljkog wrote:
On 19.12.14 23:56, Ali Çehreli wrote:
Can we see the test code please.
Ali
import std.stdio, std.datetime, std.random;
int N = 10_000;
int len = 1000;
int k = 4;
On Friday, 19 December 2014 at 23:24:13 UTC, zeljkog wrote:
On 19.12.14 23:56, Ali Çehreli wrote:
Can we see the test code please.
Ali
import std.stdio, std.datetime, std.random;
int N = 10_000;
int len = 1000;
int k = 4;
struct S{
int n1, n2;
//~ this(this){
//~ writeln(
On 19.12.14 23:56, Ali Çehreli wrote:
> Can we see the test code please.
>
> Ali
import std.stdio, std.datetime, std.random;
int N = 10_000;
int len = 1000;
int k = 4;
struct S{
int n1, n2;
//~ this(this){
//~ writeln("this(this)");
//~ }
}
ref T[] append(T, Args...)(ref
On 12/19/2014 07:42 AM, zeljkog wrote:
On 19.12.14 16:25, Steven Schveighoffer wrote:
Did you compile both tests with the same command line parameters?
Yes.
Can we see the test code please.
Ali
On 12/19/14 5:28 PM, Anonymous wrote:
What a big surprise. If you make an array of struct, each item of your
array has the length of the struct. structs a values.
If you want to append a struct to an array just append a pointer to
the struct:
--
struct arg{uint a,r,g,h;};
arg * [] argh
On Friday, 19 December 2014 at 18:38:32 UTC, Steven Schveighoffer
wrote:
On 12/19/14 12:15 PM, Anonymous wrote:
On Friday, 19 December 2014 at 15:25:46 UTC, Steven
Schveighoffer wrote:
This is surprising to me.
Ho ho ho, this year he has brought your surprise sooner than
expected...
It
On 12/19/14 12:15 PM, Anonymous wrote:
On Friday, 19 December 2014 at 15:25:46 UTC, Steven Schveighoffer wrote:
This is surprising to me.
Ho ho ho, this year he has brought your surprise sooner than expected...
It would be nice if this was the only time this year I was surprised
because
On Friday, 19 December 2014 at 15:25:46 UTC, Steven Schveighoffer
wrote:
On 12/18/14 5:27 PM, zeljkog wrote:
On 18.12.14 14:50, Steven Schveighoffer wrote:
I wonder how your code compares to this:
void append(T)(ref T[] arr, T[] args...)
{
arr ~= args;
}
This is ~20% slower for ints, but
On 12/19/14 10:42 AM, zeljkog wrote:
On 19.12.14 16:25, Steven Schveighoffer wrote:
This is surprising to me. I would expect especially ints to be faster.
In reality, there is no difference between arr ~= args and arr.length +=
args.length, and then copying, it's just how you do the copying. Per
On 19.12.14 16:25, Steven Schveighoffer wrote:
This is surprising to me. I would expect especially ints to be faster.
In reality, there is no difference between arr ~= args and arr.length +=
args.length, and then copying, it's just how you do the copying. Perhaps
it's the call to memcpy in the ru
On 12/18/14 5:27 PM, zeljkog wrote:
On 18.12.14 14:50, Steven Schveighoffer wrote:
I wonder how your code compares to this:
void append(T)(ref T[] arr, T[] args...)
{
arr ~= args;
}
This is ~20% slower for ints, but it difference increases for bigger structs.
This is surprising to me
On Thursday, 18 December 2014 at 22:27:06 UTC, zeljkog wrote:
On 18.12.14 14:50, Steven Schveighoffer wrote:
I wonder how your code compares to this:
void append(T)(ref T[] arr, T[] args...)
{
arr ~= args;
}
This is ~20% slower for ints, but it difference increases for
bigger structs.
On 18.12.14 14:50, Steven Schveighoffer wrote:
> I wonder how your code compares to this:
>
> void append(T)(ref T[] arr, T[] args...)
> {
> arr ~= args;
> }
This is ~20% slower for ints, but it difference increases for bigger structs.
On Thursday, 18 December 2014 at 15:12:39 UTC, Nordlöw wrote:
On Wednesday, 17 December 2014 at 12:30:37 UTC, Tobias Pankrath
wrote:
void append(T, Args...)(ref T[] arr, auto ref Args args){
{
static if (args.length == 1)
arr ~= args[0]; // inlined
else{
arr.length += args.length;
On Wednesday, 17 December 2014 at 12:30:37 UTC, Tobias Pankrath
wrote:
void append(T, Args...)(ref T[] arr, auto ref Args args){
{
static if (args.length == 1)
arr ~= args[0]; // inlined
else{
arr.length += args.length;
foreach(i, e; args)
arr[$ - args.length + i] =
On 12/17/14 6:15 AM, zeljkog wrote:
On 15.12.14 01:00, "Nordlöw" wrote:
Isn't this algorithm already encoded somewhere in Phobos?
void append(T, Args...)(ref T[] arr, auto ref Args args){
{
static if (args.length == 1)
arr ~= args[0]; // inlined
else{
arr.length += ar
On 17.12.14 13:30, Tobias Pankrath wrote:
void append(T, Args...)(ref T[] data, Args args)
{
static size_t estimateLength(Args args)
{
size_t result;
foreach(e; args)
static if(hasLength!(typeof(e)))
result += e.length;
else
On Wednesday, 17 December 2014 at 11:15:30 UTC, zeljkog wrote:
On 15.12.14 01:00, "Nordlöw" wrote:
Isn't this algorithm already encoded somewhere in Phobos?
void append(T, Args...)(ref T[] arr, auto ref Args args){
{
static if (args.length == 1)
arr ~= args[0]; // inlined
else{
On 15.12.14 01:00, "Nordlöw" wrote:
> Isn't this algorithm already encoded somewhere in Phobos?
void append(T, Args...)(ref T[] arr, auto ref Args args){
{
static if (args.length == 1)
arr ~= args[0]; // inlined
else{
arr.length += args.length;
foreach(i, e; args)
On Monday, 15 December 2014 at 15:55:22 UTC, Steven Schveighoffer
wrote:
What's the fastest way to append multiple elements to an
array?:
Before appending, call reserve to avoid the possibility of
reallocating multiple times:
arr.reserve(arr.length + n); // about to append n ele
On 12/14/14 6:16 PM, "Nordlöw" wrote:
What's the fastest way to append multiple elements to an array?:
Before appending, call reserve to avoid the possibility of reallocating
multiple times:
arr.reserve(arr.length + n); // about to append n elements.
Either
arr ~= e1;
On Sunday, 14 December 2014 at 23:16:12 UTC, Nordlöw wrote:
What's the fastest way to append multiple elements to an array?:
Either
arr ~= e1;
arr ~= e2;
arr ~= e3;
or
arr ~= [e1,e2,e3];
or some other trick?
It does somewhat depend on context but std.array.append
On Sunday, 14 December 2014 at 23:52:15 UTC, zeljkog wrote:
On 15.12.14 00:16, "Nordlöw" wrote:
or some other trick?
void append(T, Args...)(ref T[] arr, Args args){
arr.length += args.length;
foreach(i, e; args)
arr[$ - args.length + i] = args[i];
}
void main()
{
int[] arr = [1, 2
On 15.12.14 01:00, "Nordlöw" wrote:
Isn't this algorithm already encoded somewhere in Phobos?
I don't know.
On Sunday, 14 December 2014 at 23:52:15 UTC, zeljkog wrote:
void append(T, Args...)(ref T[] arr, Args args){
arr.length += args.length;
foreach(i, e; args)
arr[$ - args.length + i] = args[i];
}
Isn't this algorithm already encoded somewhere in Phobos?
On 15.12.14 00:16, "Nordlöw" wrote:
> or some other trick?
void append(T, Args...)(ref T[] arr, Args args){
arr.length += args.length;
foreach(i, e; args)
arr[$ - args.length + i] = args[i];
}
void main()
{
int[] arr = [1, 2, 3, 4, 5];
arr.append(3, 10, 14);
writeln(arr);
}
output
What's the fastest way to append multiple elements to an array?:
Either
arr ~= e1;
arr ~= e2;
arr ~= e3;
or
arr ~= [e1,e2,e3];
or some other trick?
38 matches
Mail list logo