[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: QList::at and so on :}
From:       David Faure <david () mandrakesoft ! com>
Date:       2001-06-27 10:38:01
[Download RAW message or body]

On Tuesday 26 June 2001 23:12, Marco Krohn wrote:
> On Tuesday 26 June 2001 17:35, Simon Hausmann wrote:
> > On Tue, Jun 26, 2001 at 05:27:13PM +0200, Werner Trobin wrote:
> > > If you see code like that:
> > >
> > > for ( uint i = 0; i < objectList()->count(); ++i ) {
> > >     object = objectList()->at( i );
> > >     object->doSomething();
> > >     object->doSomethingElse(foo);
> > > }
> 
> > Of course I fully agree with iterators being nicer :-) , just
> > wanted to point out that it is not as bad as it looks like, as the
> > Trolls were intelligent enough to catch this very case of at(int) usage.
> 
> Just as a sidenote: using the count method _in_ the loop can also be (depends 
> on the implementation) a big waste of cycles since count() is called every 
> iteration and in some implementations count() is O(N).

Nah, it's not O(N), Qt is very well written ;-)

inline uint QGList::count() const
{
    return numNodes;
}

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://perso.mandrakesoft.com/~david/, http://www.konqueror.org/
KDE, Making The Future of Computing Available Today
_______________________________________________
Koffice-devel mailing list
Koffice-devel@master.kde.org
http://master.kde.org/mailman/listinfo/koffice-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic