C + + cstringlist usage

Source: Internet
Author: User

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

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.