|
-
December 6th, 2011, 06:15 PM
#3
Re: adding to vector of vector<int>, check if element already present
 Originally Posted by Paul McKenzie
The problem, in plain English, is that the output stream has no idea how to output a path_iterator.
Code:
cout << "path_iterator " << path_iterator << endl;
Regards,
Paul McKenzie
Yes, I forgot to make the output a pointer.
This sort of gets me going,
Code:
vector<vector<int> > new_set_of_paths;
vector<int>::iterator path_iterator;
vector<int> check_path;
for(j=0; j<last_vertex_delta; j++) {
current_neighbor = vertex_list[last_vertex_in_path].neighbor_numbers[j];
if(path_length > 2) {
check_path = new_set_of_paths[path_count];
// search path to see if new atom is already part of path
path_iterator = find(check_path.begin(),
check_path.end(),
current_neighbor);
cout << "last_atom_in_path " << last_atom_in_path << endl;
cout << "current_neighbor " << current_neighbor << endl;
cout << "path_iterator " << * path_iterator << endl;
cout << endl;
}
if(path_iterator == 0) {
new_set_of_paths[path_count].push_back( current_neighbor );
path_count ++; //
}
check_path.clear();
}
I don't seem to know how to evaluate if the iterator indicates that it found a match. I can't do, if(path_iterator == 0), or if(*path_iterator == 0), and I also tried if(path_iterator > check_path.end()) and a few similar things. I can't seem to find a reference that shows how to evaluate an iterator. The * iterator value prints as 0 when a match isn't found, but I can't seem to get the syntax for working that into the conditional.
LMHmedchem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|