I'm tinkering with a list<string>. Are there any 'native' list classes/functions that handle:
Inserting new node at the end.
Deleting a known node.
starts iterating from known node.
merging strings in new node.
Hmm... can't think of all right now, but I think the message is clear enough. Do I have to make the needed methods myself or are there some super class I should know about?
list<string> l;
// Inserting new node at the end
l.push_back("1");
l.push_back("2");
l.push_back("3");
// known node
list<string>::iterator it = l.begin();
// Deleting a known node
it = l.erase(it);
// starts iterating from known node.
for (;it != l.end(); ++it)
{
cout << *it << endl;
}
//merging strings in new node
// ????
The last one... is probably somewhat elaborated to make it into a open class. He he. I'm not that familiar with the methods among the member functions.
Your examples, hmm... Are the nodes indexed by the iterator?
Oh I just thought it was kind of silly to even hope for a native method doing something like that.
Thank you!
The list will contain strings, and some other stuff. I haven't really dug into how list work yet... However, this is what I'm going to do.
1. Read a big file containing a huge string.
2. Put each row into some sort of structure, leaning against linked list.
3. Compare each row-string to see if there's a match, char by char, there seems to be plenty of string functions that will help.
4. If a match is found, merge the strings with the overlapping part as the middle part of the new string.
5. Put the new string into the last stance of the structure mentioned in 2. Erase the nodes that matched.
'Some node - dsdfagd
An other node - dgfddsd
Should be dgfddsdfagd, when done.