Rgd: Vector Iterator to get Index Position
<p>This is my iterator position code</p>

<pre><code>struct node {
int nodeid;
vector&lt;fingerTable&gt; fTable;
vector&lt;string&gt; data;
};

vector&lt;node&gt; cNode;

vector&lt;node&gt;::iterator position = find(cNode.begin(),cNode.end(), id);
</code></pre>

<p>I got about 100 objects, i am trying to find the index/element/position of e.g nodeid "80" assuming that my object is all sorted in ascending order by nodeid.</p>

<p>my concern is speed and memory usage, i was previously using </p>

<pre><code>for(int i=0;i&lt;cNode.size();i++)
{
//if logic-- match nodeid with the nodeid input.. then assign the i to an integer..
}
</code></pre>

<p>but now i am trying to use  and iterator, i heard its faster.. any suggestion on getting it fix or is there a better way to find my vector index by its value "nodeid"</p>

<p>i know map is a good std container for my case but i a bit run out of time to do the changes so i got to stick with vector..</p>

<pre><code>vector&lt;node&gt;::iterator position = find(cNode.begin(),cNode.end(), id);
</code></pre>

<p>Error output when i try compile the iterator line above.</p>

<pre><code>In member function ‘void chord::removePeer(int)’:
testfile.cpp:532:69: error: no matching function for call to ‘chord::find(std::vector&lt;chord::node&gt;::iterator, std::vector&lt;chord::node&gt;::iterator, int&amp;)’
testfile.cpp:532:69: note: candidate is:
testfile.cpp:177:5: note: int chord::find(int, int, bool)
testfile.cpp:177:5: note:   no known conversion for argument 1 from ‘std::vector&lt;chord::node&gt;::iterator {aka __gnu_cxx::__normal_iterator&lt;chord::node*, std::vector&lt;chord::node&gt; &gt;}’ to ‘int’
</code></pre>
