Re: Why use STL?



Lisa Pearlson wrote:
>> STL, but the STL's most important libraries are the iterators and
>> algorithms, which MFC doesn't cover at all!
>
> Iterators? You mean nothing more than "start()" and "end()" and ++ ?
> I apologize for my ignorance, but can't you simply build a simple
> wrapper around CArray like this:
>
> class CMyArray<TX,TY> : CArray<TX,TY>, i(-1)
> {
> private:
> int i;
> ...
> void Start() { i = GetSize() - 1; }
> void End() { i = GetSize(); }
> int operator++ ... i++ // forgot the exact syntax, but you know what
> I mean ...
> }
>
>
> Of course this doesn't fix the inefficiencies of CArray
> implementation, but it's this easy to implement itterated access.
> Or am I completely misunderstanding what "iterators" are all about?
>

Iterators are easy.

It's the fact that STL container classes don't implement any algorithms (in
general - there are a few exceptions). Rather, there are stand-alone
algorithm implementations that work generically on iterators. They can
operate on the standard containers and on any other containers you'd care to
create.

-cd


.



Relevant Pages

  • Re: Unified Ada library
    ... :> developers who think that the STL could only have been written in C++, ... Could you comment on the importance of iterators and generic ... we cannot present a standard interface to containers ...
    (comp.lang.ada)
  • Re: OO Style with Ada Containers
    ... cursor/iterator and this is different from both STL and Java (STL ... anyway - in both cases iterators can be used to query as well as to ... algorithms work on whole containers. ...
    (comp.lang.ada)
  • Re: Unified Ada library
    ... > Could you comment on the importance of iterators and generic ... You can write your algorithms for the most part as if you were ... The idea was to have containers and algorithms that did not force ... code to pay runtime abstraction penalties over use of plain arrays. ...
    (comp.lang.ada)
  • Re: Best Data Structures Book
    ... and standard algorithms persuaded me to port and adapt the SGI STL to ... Maybe you can use it or at least compare your implementations with it. ... I wish to bring to my libraries are iterators and an generic ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Unified Ada library
    ... expressed using Set Iterators in e.g. generic union and intersection ... Charles generic algorithms, AFAICS.) ... For example, all persons named "Miller" from a telephone directory, ...
    (comp.lang.ada)

Loading