Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're just going to iterate over the <code>std::vector&lt;std::string&gt;</code> without adding or removing elements (during a single iteration), then why not just use a set of pointers/iterators for the duplicates:</p> <pre><code>std::vector&lt;std::string&gt; subtreePaths = //the ones you want to iterate for ... std::set&lt;std::vector&lt;std::string&gt;::const_iterator&gt; setUniquePaths; for(auto iterS=subtreePaths.begin(); iterS!=subtreePaths.end(); ++iterS) for(auto iterP=vecPaths.begin(); iterP!=vecPaths.end(); ++iterP) if(matches(*iterP, *iterS) &amp;&amp; setUniquePaths.insert(iterP).second) std::cout &lt;&lt; *iterP &lt;&lt; std::endl; //or whatever </code></pre> <p>(of course the <code>auto</code> is C++11, feel free to replace it by a corresponding iterator type for C++98/03 compliance).</p> <p>But maybe I misunderstood what you're actually trying to achieve.</p> <hr> <p><strong>EDIT:</strong> If you don't already have all your existing paths in the <code>vecPaths</code> vector and you actually want to somehow iterate over your real file system constructing the <code>vecPaths</code> vector with all the found (and duplicate-cleaned) paths, then my above aproach is of course rubbish, since it assumes a mere string-based iteration over a known vector of all paths.</p> <p>But if that's the case, you can just drop the vector completely and use a single <code>std::set&lt;std::string&gt;</code> to collect all the paths you encounter (being automatically unique now). No need for an additional vector.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload