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

List:       kopete-devel
Subject:    [kopete-devel] Re: [PATCH] Avoiding to test on end()
From:       Richard Smith <kde () metafoo ! co ! uk>
Date:       2005-06-26 18:08:08
Message-ID: 200506261908.08702.kde () metafoo ! co ! uk
[Download RAW message or body]

On Sunday 26 June 2005 14:45, Thiago Macieira wrote:
> Olivier Goffart wrote:
> >So there are really no way to browse a QMap from the end to the
> > beginning ?
>
> It doesn't really make sense because QMaps have no specific order. So if
> you have a way of iterating from one end to another, that should suffice.

QMaps are in key order. In this case, the map is sorted by online status. You 
may have been thinking of Q*Dict, which are implemented as hash tables. In 
this case it looks like the order is important. Michel's right that the 
current code is undefined.

This should work:

Private::ProtocolMap::Iterator it = protocolMap.end();
while (it != protocolMap.begin())
{
	--it;

	// do stuff
}

As should this:

#include <iterator>

for (std::reverse_iterator<Private::ProtocolMap::Iterator> it = 
protocolMap.end(); it != protocolMap.begin(); ++it)
{
	// do stuff
}
-- 
Thanks,
Richard
_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

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