CStringList Class Members
Structure
CStringList |
constructs an empty CString Object List |
Head/tail Access
GetHead |
Returns the elements of the head in this list (which cannot be empty) |
GetTail |
Returns the elements of the tail in this list (which cannot be empty) |
Operation
RemoveHead |
Remove an element from the head of a list |
RemoveTail |
Delete an element from the end of the list |
AddHead |
Add an element to the head of the list (or all of the elements in another list) to produce a new header |
AddTail |
Add an element to the end of the list (or all of the elements in another list) to produce a new tail |
RemoveAll |
Delete all elements in this list |
Repeat
GetHeadPosition |
Returns the position of the head element in the list |
GetTailPosition |
Returns the position of the trailing element in the list |
GetNext |
Gets the next element for repetition |
GetPrev |
Gets the previous element used for repetition |
Get/Modify
GetAt |
Gets the element at the given position |
SetAt |
Sets the element at a given location |
RemoveAt |
Deletes an element specified by position from this list |
Insert
InsertBefore |
Inserts a new element before a given location |
InsertAfter |
Inserts a new element after a given location |
Search
Find |
Gets the position of the element specified by the string value |
FindIndex |
Gets the position of the element specified by a zero-based index |
State
GetCount |
Returns the number of elements in this list |
IsEmpty |
Test whether the list is empty (no elements) |
CStringList is a CString linked list, in MFC programming in addition to the STL of another choice, use more concise.
Insert data: AddTail (); AddHead ()
Delete data: RemoveAll (); RemoveAt (); RemoveHead (); RemoveTail ()
Get the number of elements: GetCount ()
Gets an element value: GetAt (Cstringlist.findindex (index))//index as an integer
Get the tail element: GetHead (); GetTail (),
Traversal is best to use the above method, do not use position variable, with FindIndex can be.
Class
CStringList Listfilename;
Listfilename.removeall ();
Add Action:
Listfilename.addtail (Szfullpathname);
Traversal operation:
POSITION RpoS;
RpoS = Listfilename.getheadposition ();
while (RpoS!= NULL)
{
strFileName = Listfilename.getnext (rpos);
Strlog + = "/r/n" + strFileName;
}
The above mentioned is the entire content of this article, I hope you can enjoy.