On Thursday, 10 April 2014 at 20:03:46 UTC, JR wrote:
In my NewlineBufferThingy struct, I sometimes need to move a
slice at an arbitrary point of an array to the very beginning
of it, like a poor man's circular buffer.
Just in case somebody is wondering, phobos has std.range.cycle
for circula
On Thursday, 10 April 2014 at 05:54:52 UTC, monarch_dodra wrote:
On Wednesday, 9 April 2014 at 23:53:04 UTC, dnspies wrote:
Does concatenation always create a new array? What if the
type of the original is immutable (or even const)? In that
case, wouldn't it be worthwhile to check first if rh
It depends on your use-case, I think. How often will you be
prepending? Will you be appending as well?
On Thursday, 10 April 2014 at 16:10:04 UTC, Steven Schveighoffer
wrote:
Note, I create a deque class in dcollections which maintains 2
arrays, one for prepending (and is in reverse order), an
On Wed, 09 Apr 2014 19:18:25 -0400, dnspies wrote:
I know that D slices are set up so you can successively append to them
and it only has to re-allocate infrequently, but what about with
prepending?
ie, does D have a way to handle
int[] x;
for(int i=0; i < 1000; i++) {
x = [i] ~ x;
}
On Wednesday, 9 April 2014 at 23:18:27 UTC, dnspies wrote:
I know that D slices are set up so you can successively append
to them and it only has to re-allocate infrequently, but what
about with prepending?
ie, does D have a way to handle
int[] x;
for(int i=0; i < 1000; i++) {
x = [i] ~ x;
On Wednesday, 9 April 2014 at 23:18:27 UTC, dnspies wrote:
I know that D slices are set up so you can successively append
to them and it only has to re-allocate infrequently, but what
about with prepending?
ie, does D have a way to handle
int[] x;
for(int i=0; i < 1000; i++) {
x = [i] ~ x;
On Wednesday, 9 April 2014 at 23:53:04 UTC, dnspies wrote:
Does concatenation always create a new array? What if the type
of the original is immutable (or even const)? In that case,
wouldn't it be worthwhile to check first if rhs can be copied
to the right of lhs?
Yes, it *always* creates a
dnspies:
Does concatenation always create a new array?
Concatenation allocated a new array (unless some compiler is able
to optimize away something in some cases, but I think this is not
yet happening).
Bye,
bearophile
On Wednesday, 9 April 2014 at 23:43:27 UTC, bearophile wrote:
dnspies:
efficiently, or is it better to avoid this sort of thing?
D arrays are dynamic on the right. So appending on their left
is not efficient (also here you are not prepending, you are
concatenating. Array concatenation creat
dnspies:
efficiently, or is it better to avoid this sort of thing?
D arrays are dynamic on the right. So appending on their left is
not efficient (also here you are not prepending, you are
concatenating. Array concatenation creates a new array). In some
cases you can append on the right man
10 matches
Mail list logo