One of STL's learning notes

zhaozj2021-02-11  201

The following is a little notes I am in my self-study, refer to the book "Standard C Collection". If you are interested in the latest C standard, I want to talk about a chat, my e-mail: tlovexyj@21cn.com

#include using namespace std; Vector Class Template VECTOR

1. Features: Random access, dynamically changed its own size, quickly insert and delete element disadvantages in the sequence tail: insertion and deletion element efficiency in the tail tail (because the elements are to accommodate new elements or recycled space)

2. Declaration VECTOR Object Name (Size, Initial Value) Example: Vector IVECTOR (100, 0); // Size is 100, type INT, the initial all value is 0.

3. Access to operate through the indicator Iterator (Pointer in C ). Declaration Vector :: Iterator Object Name: Vector :: Iterator iTer; 4. Access Traversing: for (iter = IVector .begin (); iter :: Iterator Start; IVector.insert (Start, 1); Insert (Iterator Pointer, Number, Element) // Remote Element N-Nip to Pointer Case Description: Vector :: item; tent; ivector .insert (start, 5, 1); INSERT (Iterator pointer, Iterator pointer start, Iterator pointer end) // Insert the value within the range of the operation into the specified position example: Vector :: Iterator I, Start, End I = Ivector.begin (); start = IVECTOR.BEGIN () 2; end = Ivector.end () - 3; IVector.insert (i, start, end); 6. Delete Elements (hereinafter, it is vector Class member function) POP_BACK () // Delete in the tail: IVector.push_back (); ERASE (Iterato R pointer) // Randomly delete the ERASE (Iterator pointer start, Iterator pointer end) // Delete value

转载请注明原文地址:https://www.9cbs.com/read-5064.html

New Post(0)