Re: Fastest way to "ignore" elements from array without removal

2021-02-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/16/21 1:03 AM, H. S. Teoh wrote: For the former, you can use the read-head/write-head algorithm: keep two indices as you iterate over the array, say i and j: i is for reading (incremented every iteration) and j is for writing (not incremented if array[i] is to be deleted). Each iteration, i

Re: Fastest way to "ignore" elements from array without removal

2021-02-16 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 16 February 2021 at 09:08:33 UTC, z wrote: Does filter support multiple arguments for the predicate?(i.e. using a function that has a "bool function(T1 a, T2 b)" prototype) I am not sure exactly what you are asking here, but you can probably accomplish what you want by combining f

Re: Fastest way to "ignore" elements from array without removal

2021-02-16 Thread z via Digitalmars-d-learn
On Tuesday, 16 February 2021 at 06:03:50 UTC, H. S. Teoh wrote: It depends on what your goal is. Do you want to permanently remove the items from the array? Or only skip over some items while iterating over it? For the latter, see std.algorithm.iteration.filter. The array itself is read only

Re: Fastest way to "ignore" elements from array without removal

2021-02-16 Thread z via Digitalmars-d-learn
On Tuesday, 16 February 2021 at 04:43:33 UTC, Paul Backus wrote: On Tuesday, 16 February 2021 at 04:20:06 UTC, z wrote: What would be the overall best manner(in ease of implementation and speed) to arbitrarily remove an item in the middle of an array while iterating through it? http://phobos.

Re: Fastest way to "ignore" elements from array without removal

2021-02-15 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Feb 16, 2021 at 04:20:06AM +, z via Digitalmars-d-learn wrote: > What would be the overall best manner(in ease of implementation and > speed) to arbitrarily remove an item in the middle of an array while > iterating through it? > So far i've thought about simply using D's standard [0...

Re: Fastest way to "ignore" elements from array without removal

2021-02-15 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 16 February 2021 at 04:20:06 UTC, z wrote: What would be the overall best manner(in ease of implementation and speed) to arbitrarily remove an item in the middle of an array while iterating through it? http://phobos.dpldocs.info/std.algorithm.iteration.filter.html