Re: Algorithm remove Tid

2014-01-22 Thread monarch_dodra
On Wednesday, 22 January 2014 at 16:48:45 UTC, bearophile wrote: monarch_dodra: There's no phobos solution for that, There will be. In the meantime use: items = items.remove(items.countUntil(needle)); Hum... that requires iterating the range twice for a non-RA range. And you forgot a save

Re: Algorithm remove Tid

2014-01-22 Thread bearophile
monarch_dodra: There's no phobos solution for that, There will be. In the meantime use: items = items.remove(items.countUntil(needle)); See also: https://d.puremagic.com/issues/show_bug.cgi?id=10959 Bye, bearophile

Re: Algorithm remove Tid

2014-01-22 Thread monarch_dodra
On Wednesday, 22 January 2014 at 15:41:58 UTC, bearophile wrote: monarch_dodra: Maybe you confusing the new style lambda for a "greater equal" operator? I can't make sense of your question any other way. My point was that the shown code doesn't remove only one item in presence of duplicated

Re: Algorithm remove Tid

2014-01-22 Thread bearophile
monarch_dodra: Maybe you confusing the new style lambda for a "greater equal" operator? I can't make sense of your question any other way. My point was that the shown code doesn't remove only one item in presence of duplicated ones. In this case tid are unique, but in general using that code

Re: Algorithm remove Tid

2014-01-22 Thread monarch_dodra
On Wednesday, 22 January 2014 at 13:51:51 UTC, bearophile wrote: Casper Færgemand: To remove an element, I *think* you do it this way: tids = tids.remove!(a=>a == tid)(); is that removing only 0 or 1 items? Bye, bearophile Maybe you confusing the new style lambda for a "greater equal" op

Re: Algorithm remove Tid

2014-01-22 Thread Casper Færgemand
On Wednesday, 22 January 2014 at 13:51:51 UTC, bearophile wrote: Casper Færgemand: To remove an element, I *think* you do it this way: tids = tids.remove!(a=>a == tid)(); is that removing only 0 or 1 items? Bye, bearophile It removes all items that match the tid.

Re: Algorithm remove Tid

2014-01-22 Thread bearophile
Casper Færgemand: To remove an element, I *think* you do it this way: tids = tids.remove!(a=>a == tid)(); is that removing only 0 or 1 items? Bye, bearophile

Re: Algorithm remove Tid

2014-01-22 Thread Casper Færgemand
On Wednesday, 22 January 2014 at 13:16:18 UTC, monarch_dodra wrote: Because "remove" takes an "offset" as an argument, not an element. To remove an element, I *think* you do it this way: tids = tids.remove!(a=>a == tid)(); Thanks a lot. I was trying to get that part to work, but I had a har

Re: Algorithm remove Tid

2014-01-22 Thread monarch_dodra
On Wednesday, 22 January 2014 at 12:11:22 UTC, Casper Færgemand wrote: import std.algorithm; import std.concurrency; void main() { Tid[] tids = []; Tid tid = thisTid; tids ~= tid; tids.remove(tid); } Why does this not compile? Because "remove" takes an "offset"