Re: moveAt vs opIndex

2012-05-21 Thread Jonathan M Davis
On Saturday, May 19, 2012 17:28:46 maarten van damme wrote: and something partially unrelated, how do you copy a class by value? You don't. If the class has a clone method (which would fairly typically be called dup in D), then you can clone it, but classes are reference types, not value

Re: moveAt vs opIndex

2012-05-21 Thread maarten van damme
well, they we're interfaces and it made sense to implement them as a class. On the other hand, a struct is way more efficient and works just as good. Thanks for clearing everything up.

Re: moveAt vs opIndex

2012-05-19 Thread maarten van damme
so would it be wrong to make movefront simply change the index the front is pointing at without removing a prime? And I'm coming from a java world so it would make sense to me to create that range as a class that implements a range but in most examples I see everyone using structs instead. what

Re: moveAt vs opIndex

2012-05-19 Thread maarten van damme
and something partially unrelated, how do you copy a class by value?

Re: moveAt vs opIndex

2012-05-18 Thread Jonathan M Davis
On Friday, May 18, 2012 14:21:23 maarten van damme wrote: I am trying to write a randomaccessinfinite range that returns primes using the sieve of aristotle. I am however having problems understanding the difference between moveAt and opIndex; according to dlang; ElementType opIndex(size_t

Re: moveAt vs opIndex

2012-05-18 Thread Chris Cain
In your case, I don't think you really need to define a moveAt. opIndex is what's required for a Random Access Range and it really doesn't make sense to define moveAt for your particular problem. On Friday, 18 May 2012 at 12:21:31 UTC, maarten van damme wrote: Whats the difference between

Re: moveAt vs opIndex

2012-05-18 Thread Jonathan M Davis
On Friday, May 18, 2012 14:50:31 Jonathan M Davis wrote: moveFront is used to move the front of a range for stuff like swap, when simply copying elements is too expensive. It's destructive in that the element isn't there anymore when you do that. I mean that the value isn't there. The ranges