Tue, 3 Feb 2009 18:11:35 +0100, nobody wrote:
> "Jarrett Billingsley" wrote in message
> news:mailman.637.1233680615.22690.digitalmars-d-le...@puremagic.com...
>> On Tue, Feb 3, 2009 at 11:51 AM, nobody wrote:
>>> Would you also happen to know why the following gives an error?
>>>
>>> arr[1] =
Please tell me when I got something wrong : )
>>>
>>> arr = arr[ 0 .. lowerBound ] ~ arr[ upperBound .. $ ];
>>>
>>
>> That's simple enough, but inefficient.
Because it loops over arr.length-2 and copies the pointers.
Will the compiler optimize by not copying the [0..lowerbound] part?
And will the
"Jarrett Billingsley" wrote in message
news:mailman.637.1233680615.22690.digitalmars-d-le...@puremagic.com...
> On Tue, Feb 3, 2009 at 11:51 AM, nobody wrote:
>> Would you also happen to know why the following gives an error?
>>
>> arr[1] = arr[$-1];// main.d(11): Error: cannot assign to s
On Tue, Feb 3, 2009 at 11:51 AM, nobody wrote:
> Would you also happen to know why the following gives an error?
>
> arr[1] = arr[$-1];// main.d(11): Error: cannot assign to static array
arr[1][] = arr[$-1][];
You cannot reassign what fixed-size array references point to, but you
can copy t
"Jarrett Billingsley" wrote in message
news:mailman.636.1233678501.22690.digitalmars-d-le...@puremagic.com...
> On Tue, Feb 3, 2009 at 10:54 AM, nobody wrote:
>> Let's see if I understand memmove..
>> The way it's used here, it copies the tail of an array onto that same
>> array,
>> only start
On Tue, Feb 3, 2009 at 10:54 AM, nobody wrote:
> Let's see if I understand memmove..
> The way it's used here, it copies the tail of an array onto that same array,
> only starting one index earlier, thus removing the undesired element?
> Neat.
Right.
> However I just realized that order does not
"Jarrett Billingsley" wrote in message
news:mailman.635.1233675301.22690.digitalmars-d-le...@puremagic.com...
> On Tue, Feb 3, 2009 at 10:14 AM, Frank Benoit
> wrote:
>>
>> arr = arr[ 0 .. lowerBound ] ~ arr[ upperBound .. $ ];
>>
>
> That's simple enough, but inefficient.
>
> Something like th
"Frank Benoit" wrote
> nobody schrieb:
>> "Denis Koroskin" <2kor...@gmail.com> wrote in message
>> news:op.uor1gzqho7c...@korden-pc...
>>> On Tue, 03 Feb 2009 15:46:52 +0300, nobody
>>> wrote:
>>>
What is the best way to completely remove an element from an array?
For example you h
"Frank Benoit" wrote in message
news:gm9n0e$314...@digitalmars.com...
> nobody schrieb:
>> "Denis Koroskin" <2kor...@gmail.com> wrote in message
>> news:op.uor1gzqho7c...@korden-pc...
>>> On Tue, 03 Feb 2009 15:46:52 +0300, nobody
>>> wrote:
>>>
What is the best way to completely remove a
On Tue, Feb 3, 2009 at 10:14 AM, Frank Benoit
wrote:
>
> arr = arr[ 0 .. lowerBound ] ~ arr[ upperBound .. $ ];
>
That's simple enough, but inefficient.
Something like this:
import std.c.string; // or import tango.stdc.string;
T[] erase(T)(ref T[] arr, size_t idx)
{
if(arr.length == 0)
nobody schrieb:
> "Denis Koroskin" <2kor...@gmail.com> wrote in message
> news:op.uor1gzqho7c...@korden-pc...
>> On Tue, 03 Feb 2009 15:46:52 +0300, nobody wrote:
>>
>>> What is the best way to completely remove an element from an array?
>>>
>>> For example you have an array:
>>> [1,2,3,4,5,6]
>>
"Denis Koroskin" <2kor...@gmail.com> wrote in message
news:op.uor1gzqho7c...@korden-pc...
> On Tue, 03 Feb 2009 15:46:52 +0300, nobody wrote:
>
>> What is the best way to completely remove an element from an array?
>>
>> For example you have an array:
>> [1,2,3,4,5,6]
>> and want to remove eleme
On Tue, 03 Feb 2009 15:46:52 +0300, nobody wrote:
What is the best way to completely remove an element from an array?
For example you have an array:
[1,2,3,4,5,6]
and want to remove element "3" in such a way that the resulting array is:
[1,2,4,5,6]
Thanks.
import std.array;
auto arr = [0
What is the best way to completely remove an element from an array?
For example you have an array:
[1,2,3,4,5,6]
and want to remove element "3" in such a way that the resulting array is:
[1,2,4,5,6]
Thanks.
14 matches
Mail list logo