欢迎来到天天文库
浏览记录
ID:49411135
大小:899.00 KB
页数:46页
时间:2020-02-06
《数据结构与算法分析_C++语言描述(第2版)Larry_Nyhoff__.ppt》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、1MainIndexContentsCLASSlistConstructorsCLASSlistOperationsApplication:AListPalindromeiteratorOperationsConstantIteratorsDeclaringandUsingIteratorsInsertinganelementintoalistRemovinganelementfromalistTheFunctionwriteList()TheFunctionfind_last_of()TheS
2、equentialSearchofaListSplicingtwolistsOrderedlistsRemovingDuplicatesSummarySlidesChapter11–TheListContainerandIterators1Shiftingblocksofelementstoinsertordeleteavectoritem23MainIndexContentsModelofalistobjectwithlinkstonextandpreviouselement3Sampleli
3、st45MainIndexContentsTheListAPIThelistAPIdocumentsthememberfunctionprototypeaswellaspre-andpostconditions.providesthreeconstructorstodeclarealistobject.56MainIndexContentsCLASSlistConstructorslist();Createanemptylist.Thisisthedefaultconstructor
4、.list(intn,constT&value=T());Createalistwithnelements,eachhavingaspecifiedvalue.Ifthevalueargumentisomitted,theelementsarefilledwiththedefaultvaluefortypeT.TypeTmusthaveadefaultconstructor,andthedefaultvalueoftypeTisspecifiedbythenotationT().list(T*f
5、irst,T*last);Initializethelist,usingtheaddressrange[first,last).67MainIndexContentsCLASSlistOperationsT&back();Returnthevalueoftheitemattherearofthelist.Precondition:Thelistmustcontainatleastoneelement.boolempty()const;Returntrueifthelistisempt
6、y,falseotherwise.T&front();Returnthevalueoftheitematthefrontofthelist.Precondition:Thelistmustcontainatleastoneelement.78MainIndexContentsCLASSlistOperationsvoidpush_back(constT&value);Addavalueattherearofthelist.Postcondition:Thelisthasanewele
7、mentattherear,anditssizeincreasesby1.voidpop_back();Removetheitemattherearofthelist.Precondition:Thelistisnotempty.Postcondition:Thelisthasanewelementattherearorisempty.89MainIndexContentsCLASSlistOperationsvoidpush_front(constT&value);Addavalu
8、eatthefrontofthelist.Postcondition:Thelisthasanewelementatthefront,anditssizeincreasesby1.voidpop_front();Removetheitematthefrontofthelist.Precondition:Thelistisnotempty.Postcondition:Thelisthasanewelementatthefrontorisempty.intsize()const;Returnthen
此文档下载收益归作者所有