qt-interest@trolltech.com
[Top] [All Lists]

## RE: Différence of QStringLists

 Subject: RE: Différence of QStringLists "Scott Aron Bloom" Tue, 31 Oct 2006 10:51:06 -0800
 ```Just hope the lists arent that long... thats a O(N^2) algorithm If the lists are sorted, you may want to consider just using the STL algorithm, if they are unsorted, you could presort, or convert 1 to a set, and then iterate and use the contains on the set. Then its down to a NlogN algorithm Scott ________________________________ From: Justin Noel [mailto:justin@xxxxxxx] Sent: Tue 10/31/2006 9:56 AM To: qt-interest Subject: Re: Différence of QStringLists max wrote: > > Is there a simple way to make the difference of two QStringLists ? > QStringList list1 = a, b, c, d; > QStringList list2 = b, c; > > QStringList res = list1 - list2; > > res = a, d; > Max, How about: QStringList res; foreach(QString str, list1) { if( !list2.contains(str) ) res << str; } --Justin -- To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body. List archive and information: http://lists.trolltech.com/qt-interest/ ```
 Current Thread Différence of QStringLists, max Re: Différence of QStringLists, Chris Thompson Re: Différence of QStringLists, Justin Noel RE: Différence of QStringLists, Scott Aron Bloom <= Re: Différence of QStringLists, Justin Noel Re: Différence of QStringLists, Bernd Brandstetter Re: Différence of QStringLists, Andreas Pakulat