I found some linked list code on TheoryOfProgramming.com, I'm trying to edit the code to print a tuple instead of a pair with an iterator.
Is it possible to declare member variables in a tuple (similar to pairs)? If not, how would I would use an iterator to print the data?
The direct url is here http://theoryofprogramming.com/adjacency-list-using-cpp-stl/
vector< list< tuple<int, int,int> > > adjacencyList(vertices + 1);
printf("Enter the Edges V1 -> V2, of weight W\n");
for (int i = 1; i <= edges; ++i) {
scanf("%d%d%d,%d", &v1, &v2, &weight,&time);
// Adding Edge to the Directed Graph
adjacencyList[v1].push_back(make_tuple(v2, weight,time));
}
printf("\nThe Adjacency List-\n");
// Printing Adjacency List
for (int i = 1; i < adjacencyList.size(); ++i) {
printf("adjacencyList[%d] ", i);
list< tuple<int, int,int> >::iterator itr = adjacencyList[i].begin();
while (itr != adjacencyList[i].end()) {
printf(" -> %d(%d)", (*itr).first, (*itr).second,(*itr).third);
++itr;
}
printf("\n");
}