C + + cstringlist usage detailed _c language

Source: Internet
Author: User
Tags repetition

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.