<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Best way to do pattern matching in QList]]></title><description><![CDATA[<p dir="auto">Hello, I need to match a pattern of about length 10, in a QList&lt;qint8&gt; of about size 50.  All elements are either 0 or 1.  The pattern may exist multiple times and I may need to find all of them.  Any suggestions how to do this easily?  I am not finding any QList compare functions.</p>
<p dir="auto">Currently I am doing the following, but not very convenient:</p>
<p dir="auto">@    for( int i=0; i&lt;bits.size()-10; i++ )<br />
{<br />
if( <a href="http://bits.at" target="_blank" rel="noopener noreferrer nofollow ugc">bits.at</a>(i)==0 &amp;&amp; <a href="http://bits.at" target="_blank" rel="noopener noreferrer nofollow ugc">bits.at</a>(i+1)==0 &amp;&amp; <a href="http://bits.at" target="_blank" rel="noopener noreferrer nofollow ugc">bits.at</a>(i+2)==0 &amp;&amp; <a href="http://bits.at" target="_blank" rel="noopener noreferrer nofollow ugc">bits.at</a>(i+3)==0<br />
&amp;&amp; <a href="http://bits.at" target="_blank" rel="noopener noreferrer nofollow ugc">bits.at</a>(i+4)==0 &amp;&amp; <a href="http://bits.at" target="_blank" rel="noopener noreferrer nofollow ugc">bits.at</a>(i+5)==0 &amp;&amp; <a href="http://bits.at" target="_blank" rel="noopener noreferrer nofollow ugc">bits.at</a>(i+6)==0 &amp;&amp; <a href="http://bits.at" target="_blank" rel="noopener noreferrer nofollow ugc">bits.at</a>(i+7)==0<br />
&amp;&amp; <a href="http://bits.at" target="_blank" rel="noopener noreferrer nofollow ugc">bits.at</a>(i+8)==1 &amp;&amp; <a href="http://bits.at" target="_blank" rel="noopener noreferrer nofollow ugc">bits.at</a>(i+9)==0 )<br />
...<br />
@<br />
Thanks<br />
Ron</p>
]]></description><link>https://forum.qt.io/topic/43801/best-way-to-do-pattern-matching-in-qlist</link><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 23:08:20 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/43801.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 Jul 2014 18:46:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Best way to do pattern matching in QList on Fri, 18 Jul 2014 23:56:06 GMT]]></title><description><![CDATA[<p dir="auto">I'm also interested to know. Let's see if some other idea pops up!</p>
]]></description><link>https://forum.qt.io/post/236370</link><guid isPermaLink="true">https://forum.qt.io/post/236370</guid><dc:creator><![CDATA[BlastDV]]></dc:creator><pubDate>Fri, 18 Jul 2014 23:56:06 GMT</pubDate></item><item><title><![CDATA[Reply to Best way to do pattern matching in QList on Fri, 18 Jul 2014 17:09:20 GMT]]></title><description><![CDATA[<p dir="auto">That is a good idea BlastDV.  Maybe there is some easy way to compare a QList to a section of another QList.</p>
]]></description><link>https://forum.qt.io/post/236340</link><guid isPermaLink="true">https://forum.qt.io/post/236340</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 18 Jul 2014 17:09:20 GMT</pubDate></item><item><title><![CDATA[Reply to Best way to do pattern matching in QList on Fri, 18 Jul 2014 03:56:15 GMT]]></title><description><![CDATA[<p dir="auto">That's actually doing the job but if you want to save code or do it someway different, you could try:</p>
<h1>Create an empty QString</h1>
<h1>Create a <em><em>for</em></em> to iterate trough all 10 values</h1>
<h1>On every iteration, append the current value to you QString</h1>
<h1>After the for ends, compare whatever pattern you want with your QString.</h1>
<p dir="auto">@<br />
if (QString==QString)<br />
{<br />
// your code<br />
}<br />
@</p>
<p dir="auto">This may look longer to code, but it will allow you to compare what you have with any pattern, as well as they are the same size.</p>
]]></description><link>https://forum.qt.io/post/236248</link><guid isPermaLink="true">https://forum.qt.io/post/236248</guid><dc:creator><![CDATA[BlastDV]]></dc:creator><pubDate>Fri, 18 Jul 2014 03:56:15 GMT</pubDate></item></channel></rss>