[your code here]

Manfred Nowak svv1999 at hotmail.com
Sat Feb 4 20:05:01 PST 2012


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.

-manfred


More information about the Digitalmars-d mailing list