|
|
Darren New <dne### [at] sanrrcom> wrote:
> Invisible wrote:
> > You can now write a sorting algorithm once for each container type (or
> > even once overall if you desire, but that's probably less efficient) and
> > you're done. This one sorting algorithm can then be reused anywhere you
> > need to sort data.
> I can already do that in C. Look at the qsort routine.
Except that C's qsort can only be used to sort arrays, and additionally
each element must be addressable with a void*. Thus it cannot be used to
sort all possible (random access) data containers. (For example the data
container might not be a contiguous array, such as eg. a std::deque isn't,
or the array iterator might not be castable to and from void*, eg. because
it's larger than a single pointer.)
(Not to talk about casting to and from void* is completely type-unsafe,
but that's another matter, of course.)
> You're not
> talking about OO here. You're talking about how statically typed
> something is regardless of whether it's OO.
Specific algorithms are not good examples of OOP. Data containers are.
--
- Warp
Post a reply to this message
|
|