CStringList class member
?
Structure
CStringList |
constructs an empty CString Object List |
First / Tail Access
| gethead |
Returns the element of the head in this list (cannot be empty) |
| gettail |
return elements in this list (not empty) in the tail |
Operation
RemoveHead |
Remove an element from the head of the list |
RemoveTail |
Remove an element from the tail of the list |
AddHead |
Add an element (or all elements from another list) to the head of the list, creating a new header |
AddTail |
Adds an element at the end of the list (or all elements in another list), which produces a new tail |
RemoveAll |
Delete all the 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 for repetition |
Get / Modify
GetAt |
Gets the element at the given position |
SetAt |
Sets the element at the given position |
RemoveAt |
Removes an element specified by a location from this list |
Insert
insertafter
| insertbefore |
insert a new element before a given position |
| insert a new element after a given position |
search
| find |
Get 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 list is empty (no element) |
CStringList is a CString linked list, in MFC Programming in addition to the STL alternative , use more concise .
Insert Data: AddTail () ; AddHead ()
Delete data: RemoveAll (); RemoveAt (); RemoveHead (); RemoveTail ()
number of elements obtained: GetCount ()
get an element value: GetAt (Cstringlist.findindex (index))//index as an integer
get the kinsoku elements: GetHead () ; GetTail (),
traversal is best used in the way above, do not use POSITION variable, with FindIndex you can do it.
Initialization
CStringList Listfilename;
Listfilename.removeall ();
??
To add an action:
Listfilename.addtail (Szfullpathname);
??
Traversal operations:
POSITION RpoS;
RpoS = Listfilename.getheadposition ();
while (rpos! = NULL)
{
strFileName = Listfilename.getnext (RpoS);
Strlog + = "/r/n" + strFileName;
}
C + + cstringlist usage