On 2/4/12 10:05 PM, Manfred Nowak wrote:
Jos van Uden wrote:

bool isPangram

The presented code is not an acceptable example for the usage of the D
programming language.

1)
`indexOf( s, c)' has a worst case running time of O( `s.length').
`indexOf' is called once for each `c' in the used member `alpha' of
`Alphabet'.
Therefore the runtime of the presented code is
   O( `s.length' * `alpha.length')
whereas
   O( `s.length' + `alpha.length')
is possible.

2)
The optional third parameter of `indexOf' can be called with
`CaseSensitive.no'. But that parameter is left untouched. Instead a
check with `toUpper( c)' is used, thereby risking a further visitation
of the whole string .

3)
The use of the literal value `-1' stands out of the code and hints to a
maldesign in phobos. This is because `-1' is not mnemonic.

Sensible arguments. Would you want to redo the example in better style?

Andrei

Reply via email to