Re: algorithm API design question

2013-09-30 Thread Timon Gehr
On 09/30/2013 05:45 PM, Andrei Alexandrescu wrote: B-M has significant preprocessing costs, so it's not appropriate for all cases. A function specialized in finding runs would be optimal without preprocessing. ... I guess another point is that Boyer-Moore requires more capabilities of the i

Re: algorithm API design question

2013-09-30 Thread Timon Gehr
On 09/30/2013 05:45 PM, Andrei Alexandrescu wrote: On 9/30/13 5:04 AM, Timon Gehr wrote: On 09/30/2013 11:59 AM, Peter Alexander wrote: On Monday, 30 September 2013 at 09:15:22 UTC, Timon Gehr wrote: On 09/30/2013 04:35 AM, Andrei Alexandrescu wrote: 2. We should statically specialize find(r1

Re: algorithm API design question

2013-09-30 Thread Andrei Alexandrescu
On 9/30/13 5:04 AM, Timon Gehr wrote: On 09/30/2013 11:59 AM, Peter Alexander wrote: On Monday, 30 September 2013 at 09:15:22 UTC, Timon Gehr wrote: On 09/30/2013 04:35 AM, Andrei Alexandrescu wrote: 2. We should statically specialize find(r1, r2) for the case r2 is an instance of Repeat. The

Re: algorithm API design question

2013-09-30 Thread Andrei Alexandrescu
On 9/30/13 2:15 AM, Timon Gehr wrote: What is the optimization that would the specialized algorithm run faster though? Upon mismatch, restart search right after the mismatch point. Andrei

Re: algorithm API design question

2013-09-30 Thread Timon Gehr
On 09/30/2013 11:59 AM, Peter Alexander wrote: On Monday, 30 September 2013 at 09:15:22 UTC, Timon Gehr wrote: On 09/30/2013 04:35 AM, Andrei Alexandrescu wrote: 2. We should statically specialize find(r1, r2) for the case r2 is an instance of Repeat. The specialization runs the tailored algori

Re: algorithm API design question

2013-09-30 Thread Peter Alexander
On Monday, 30 September 2013 at 09:15:22 UTC, Timon Gehr wrote: On 09/30/2013 04:35 AM, Andrei Alexandrescu wrote: 2. We should statically specialize find(r1, r2) for the case r2 is an instance of Repeat. The specialization runs the tailored algorithm. The user is supposed to call e.g. find(r,

Re: algorithm API design question

2013-09-30 Thread Timon Gehr
On 09/30/2013 04:35 AM, Andrei Alexandrescu wrote: I need a function that finds a run of length k of elements equal to x in a range r, and I presume such a simple yet nontrivial algorithm (a dozen-liner) should be part of std.algorithm. This raises an interesting question - what form should the

algorithm API design question

2013-09-29 Thread Andrei Alexandrescu
I need a function that finds a run of length k of elements equal to x in a range r, and I presume such a simple yet nontrivial algorithm (a dozen-liner) should be part of std.algorithm. This raises an interesting question - what form should the API have. I see three options: 1. The existing