I’m attempting to use a linked list implementation to modify another linked list.
Here’s a example of what I’m trying to do.
list<int>list1;
list<int>list2;
list1.push_back( 1 ); // < --- want to modify this list
list1.push_back( 2 );
list2.push_back( 1 ); // with this list
In short, I want to use list2 as kind of like a variable to modify list1. I’ve done some research seems like I can’t access the nodes of the list like an array. Is there a container that allows me to easily add and remove nodes to it and compare and modify it with other containers? I was thinking sets may be an alternative, but it seems as though I can’t access the values in the set either. Any help or evidence would be great. Thanks in advance.
EDIT:::
I’m looking to create a sudoku solver. I put all 81 digits ( blank and given ) into “linked list”. I am now looking to remove possible candidates from each “list” that represents 1 cell.
For example
listlist1;
listlist2;
list1.push_back( 1 );
list1.push_back( 2 );
list2.push_back( 1 );
I now want to use list2 like this
list1.remove( list2(?) ); // < -- this obviously isn't possible due to how nodes are stored.
I hope that clears up my question a bit. This is the way I’m using to solve simple sudokus and I’ll implement a brute force technique later.
Here’s is one way, no doubt there’s others. It does depend on exact what you circumstance is. For instance if your lists are sorted there are better way than this.