Choosing between enum arrays or AliasSeqs
Nordlöw via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 25 10:50:48 PDT 2017
On Friday, 25 August 2017 at 08:27:41 UTC, Jacob Carlborg wrote:
> Since you're converting the returned index to a bool, can't you
> use "canFind" instead?
>
> immutable englishIndefiniteArticles = [`a`, `an`];
> bool isEnglishIndefiniteArticle(S)(S s)
> {
> return englishIndefiniteArticles.canFind(s);
> }
`s.canFind` has time-complexity O(s.length)
Opposite to the template-parameter overload of `among` which has
O(1), making all the difference performance-wise in my case.
More information about the Digitalmars-d-learn
mailing list