stringstream key("") ;This sets the buffer to a null string then outputs "KEYID" and the integer. The key.str() function returns the buffer as a string. As a proof that the list built and populated successfully you can call the findkey function or uncomment List.printList(). Both use a while loop which starts at the m_head and loops through the entire list.
key << "KEYID:" << i;
element->key= key.str() ;
Finally the killList() function is called from the destructor and frees up all of the items in the list.
The great thing with pointers is that you are free to construct sophisticated and complex data storage methods according to your needs though the STL and Boost.org website provide many more that are well written and you may save considerable time (and hair) not having to debug your own.
Data Structures
This list is useful for storing items in memory and processing them by one by one. It's not so good say for accessing any individual element directly (called random access) as getting an element out of the list requires that you have to count forward from the head which slows it down. This is how the Length() method works. You could add this functionality by creating an index array of pointers and as each element is added to the list, use the id to store each element's address in this array.It really depends on how you intend to use the storage- do you want random or serial access, fast addition and removal of elements etc? This is where the different storage data structures can be used. Some databases use binary trees for fast access.
On the next page : Function Pointers

