Pre {Line-Height: 1; color: #800080; Background-color: # d2c39b; font-size: 16px ;}. sysfunc {color: #627cf6; font-style: italic; font-weight: bold ;}. selffuc {color: #0ed896 ;}. bool {color: # d2576f ;}. condition {color: #000080; font-weight: bold ;}. key {color: #000080 ;}. vaR {color: #008080; font-style: italic ;}. digit {color: # ff00ff; font-weight: bold ;}. includepre {color: #800080 ;}. operator? {Color: # a776df; font-weight: bold ;}
1? Clear all elements
????m_itemVector.clear();??
2? Traversal
????vector<ITEM_CHECK>::iterator?iter=m_itemVector.begin();??????for(i=0;iter!=m_itemVector.end();iter++,i++)??????{??????????if(iter->flag==-1)??????????{??????????????break;??????????}??????????iter->flag=1;??????}??
???? Vector <item_check>: iterator? Iter = m_itemvector.begin ();?????? For (I = 0; iter! = M_itemvector.end (); ITER ++, I ++ )?? // Cancel all ?????? {?????????? ITER-> flag = 0 ;??????}??
3? Delete a qualified item
???? Int? Currentcount = (INT) m_itemvector.size ();?????? For (Int? I = 0; I <currentcount; I ++ )?????? {?????????? If (m_itemvector.at (I). Flag = 1 )?????????? {?????????????? M_itemvector.erase (m_itemvector.begin () + I );?????????????? Deleteitem (I );?????????????? This-> invalidate ();?????????????????????? Currentcount --;?????????????? I --;???????????????????????? // After deleting the position I, You need to re-determine whether the position I meets the conditions, therefore, I --.??????????}??????}??
4 ?? Traverse in positive order? Then traverse in reverse order
???? Vector <item_check>: iterator? Iter = m_itemvector.begin ();?????? For (I = 0; iter! = M_itemvector.end (); ITER ++, I ++ )?? // Cancel all ?????? {?????????? ITER-> flag = 0 ;??????}???????????? For? (; I> 0 ;)??????????????????????? // Set from the back to the front ?? ITER? Return to begin ()? What else? A problem occurs ?????? {???????????????? ITER --;?? // Return to begin ()?????????? I --;?????????? ITER-> flag = 1 ;??????}??
5? Search in Vector
???? # Include <vector> ?????? # Include <algorithm> ?? // Search ?????? Using? Namespace? STD ;??
???? Vector <int>? L ;?????? L. push_back (? 1 ?);?????? L. push_back (? 2 ?);?????? L. push_back (? 3 ?);?????? L. push_back (? 4 ?);?????? L. push_back (? 5 ?);?????? Vector <int >:: iterator? Result? =? Find (? L. Begin (?),? L. End (?),? 3 ?);? // Search for 3 ?????? If? (? Result? ==? L. End (?)?)? // Not found ?????????? Cout? <? "No "? <? Endl ;?????? Else? // Locate ?????????? Cout? <? "Yes "? <? Endl ;??
Used in this article? Calligraphy and painting novel software? Released, the content has nothing to do with the software, and the painting and calligraphy novel software? More comfortable reading, more comfortable writing, and easier Publishing.
Vector container summary. xml