On 2019-06-12 13:58:49 +, Meta said:
There are two versions of find that can find a range within another:
https://dlang.org/phobos/std_algorithm_searching.html#.find
https://dlang.org/phobos/std_algorithm_searching.html#.find.3
Thanks, that looks good. I read the find docs, but somehow di
On Wednesday, 12 June 2019 at 06:57:55 UTC, Robert M. Münch wrote:
If you use an associative array or a set, it's O(n) time and
O(n) space.
I don't see how this is the case. The AA itself has some
overhead too. So, the checking loop is O(n) but the AA lookups
not.
Hash table insertion and l
On Tuesday, 11 June 2019 at 17:12:17 UTC, Robert M. Münch wrote:
Is there a simple and elegant way to do this? Or is just using
a foreach(...) with canFind() the best way?
There are two versions of find that can find a range within
another:
https://dlang.org/phobos/std_algorithm_searching.ht
On 2019-06-11 17:34:00 +, Paul Backus said:
It's a space/time tradeoff. foreach with canFind is O(n^2) time and O(1) space.
Yes, that's why I asekd. They haystack is most likely >10 times larger
than the needles. Speed has priority.
If you use an associative array or a set, it's O(n) t
On Tuesday, 11 June 2019 at 17:12:17 UTC, Robert M. Münch wrote:
Is there a simple and elegant way to do this? Or is just using
a foreach(...) with canFind() the best way?
I made it this way, I consider it elegant. I don't know if others
will like it.
Here it is:
import std.stdio : writeln;
i
On Tuesday, 11 June 2019 at 18:39:38 UTC, KnightMare wrote:
probably strstr
https://dlang.org/library/core/stdc/string/strstr.html
implemented over it. there is a tendency to remove dependency
from C-runtime.
*FIX*
strpbrk
https://dlang.org/phobos/core_stdc_string.html#.strpbrk
On Tuesday, 11 June 2019 at 17:12:17 UTC, Robert M. Münch wrote:
Is there a simple and elegant way to do this? Or is just using
a foreach(...) with canFind() the best way?
not elegant, not simple. for byte/short/ubye/ushort only
https://www.strchr.com/strcmp_and_strlen_using_sse_4.2
https://dla
On Tuesday, 11 June 2019 at 17:12:17 UTC, Robert M. Münch wrote:
Is there a simple and elegant way to do this? Or is just using
a foreach(...) with canFind() the best way?
It's a space/time tradeoff. foreach with canFind is O(n^2) time
and O(1) space. If you use an associative array or a set,
On Tuesday, 11 June 2019 at 17:12:17 UTC, Robert M. Münch wrote:
Is there a simple and elegant way to do this? Or is just using
a foreach(...) with canFind() the best way?
There is also find_among, but the performance is the same, I
assume.
https://dlang.org/library/std/algorithm/searching/fi
Is there a simple and elegant way to do this? Or is just using a
foreach(...) with canFind() the best way?
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
10 matches
Mail list logo