Dividing a vector into smaller vectors upon its properties
<p>I want to write something in C++, and although I have the idea and I have tried to write it I don't achieve how to do it.</p>

<p><strong>Explanation</strong></p>

<p>Imagine that I have a <code>vector&lt;int&gt;</code> that we define eveytime we run our program. Its name is <code>mainVector</code> This vector will have a random number of ints. And every int will have a property.</p>

<p>For example, we have the vector with the following values: <code>vector&lt;int&gt; mainVector {1, 3, 15, 33, 35, 42, 57, 69, 73}</code>;
and we have another <code>vector&lt;int&gt;</code> which describe the properties of every element in mainVector upon the position of the element, called <code>properties</code> for example: <code>vector&lt;int&gt; properties {1, 1, 1, 2, 2, 2, 3, 3, 3}</code></p>

<p>What I want now, is to divide the first vector in as many smaller vectors as different properties exist. For example, in the last case, I would have three new vectors: Vector with elements with property 1: <code>1, 3, 15</code>; vector with elements with property 2: <code>33, 35, 42</code>; and vector with elements with property 3: <code>57, 69, 73</code>.</p>

<p>The problem is that I don't know how to define this, cause the first vector can be different everytime we execute our code.</p>

<p>Here I attached you the code with my ideas:</p>

<pre><code>do
{
    for(int t=0;t&lt;mainVector.size();t++) // id tables
    {
        string Vect("Vector");
        Vect +=t;
        vector&lt;int&gt; Vect

        for(int u=0;u&lt;mainVector.size();u++)
      {
            if(properties.at(u) &amp; t)
            {
               Vect.push_back(mainVector.at(u)); // I know this is not correct but I hope you understand what I mean
            }
        }
    }
}
</code></pre>

<p>Thanks in advance to all of you!!! :)</p>

<p><strong>Clarification</strong></p>

<p>Something important that I want to clarify: <code>mainVector</code> is already a subvector of another bigger vector that has been defined thanks to an imput. <code>bigVector &lt;int&gt;</code> is <code>{1, 2, 3, 4, 5, 6, ...., 99, 100, 101, ..., n}</code> and <code>vector &lt;int&gt; properties</code> is a vector, actually, as big a bigvector that can be different in any case, so for example, in one execution i can be <code>{1, 1, 1, 1, 1, 1, ..., 1, 1, 2, ... 2}</code> and ion another moment <code>{1, 1, 1, 1, 2, 2, ..., 26, 26, 27, 49}</code> so I think I can't do a vector of vectors as some of you are recommending, any idea??</p>

<p>Thanks once more!!!</p>
