c05p245.txt

来自「Data Abstraction & Problem Solving with 」· 文本 代码 · 共 71 行

TXT
71 行
字号
template <class T> class std::vector{public:   vector()   // Default constructor   // Precondition: None.   // Postcondition: An empty vector exists.   vector(size_type n)   // Creates a vector with n elements   // Precondition: None.   // Postcondition: A vector of n elements exists.   bool empty() const;   // Determines whether the vector is empty.   // Precondition: None.   // Postcondition: Returns true if the vector is empty,   // otherwise returns false.   size_type size() const;   // Determines the length of the vector.   // The return type size_type is an integral type.    // Precondition: None.   // Postcondition: Returns the number of items that   // are currently in the vector.   void push_back(const T&);   // Inserts a new element at the end of the vector.   // Precondition: None.   // Postcondition: The new element is the last element   // in the vector.   void pop_back();   // Removes the last element of the vector.   // Precondition: There is at least one element in the vector.   // Postcondition: The last element of the vector is removed.   iterator insert(iterator i, const T& val);	   // Inserts an item val into the vector.   // before the element specified by the iterator i.     // Precondition: The iterator is initialized.   // Postcondition: Item val is inserted into the vector and   // an iterator to the newly inserted item is returned.       iterator erase(iterator i);   // Removes element at i.   // Precondition: The iterator must be initialized.   // Postcondition: Returns an iterator to the item    // following the removed item.    void clear();   // Erases all the elements in the vector.   // Precondition: None.   // Postcondition: The vector has no elements.    iterator begin();   // Returns an iterator to the first element in the   // vector.   // Precondition: None.   // Postcondition: If the vector is empty,   // the value returned by end() is returned.    iterator end();   // Returns an iterator to test for the end of the   // vector.   // Precondition: None.   // Postcondition: The value for the end of the vector was   // returned.}  // end STL vector 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?