Why Strings as Classes?

Dee Girl deegirl at noreply.com
Wed Aug 27 15:19:39 PDT 2008


Derek Parnell Wrote:

> On Wed, 27 Aug 2008 16:33:24 -0400, Nick Sabalausky wrote:
> 
> > A generic algoritm has absolutely no business caring about the complexity of 
> > the collection it's operating on.
> 
> I also believe this to be true.

It is true. But only if you take out of context. An algorithm does not need to know the complexity of collection. But it must have a minim guarantee of what iterator the collection has. Is it forward only, bidirectional, or random access? This is small interface. And very easy to implement. Inside the iterator can do the thing it needs to access collection. Algorithm must not know it! Only ++, *, [] and comparison. That is why in STL algorithms are so general. Because they work with very small (narrow) interface. Thank you, Dee Girl



More information about the Digitalmars-d mailing list