📄 c04p224.txt
字号:
template <class T> class std::list{public: list(); // Default constructor; initializes an empty list. // Precondition: None. // Postcondition: An empty list exists. list(size_type num, const T& val = T()); // Constructor; initializes list to have num elements // with the value val. // Precondition: None. // Postcondition: A list with num elements. list(const list<T> & anotherList); // Constructor; initializes list to have the same // elements as list anotherList. // Precondition: None. // Postcondition: A list with the same elements as // anotherList. bool empty() const; // Determines whether a list is empty. // Precondition: None. // Postcondition: Returns true if the list is empty; // otherwise returns false. size_type size() const; // Determines the length of the list. size_type is // an integral type. // Precondition: None. // Postcondition: Returns the number of items that // are currently in the list. size_type max_size(); // Determines the maximum number of items the list // can hold. // Precondition: None. // Postcondition: Returns the maximum number of items. iterator insert(iterator i, const T& val = T()); // Inserts an item val into the list immediately // before the element specified by the iterator i. // Precondition: The iterator must be initialized, even // if the list is empty. // Postcondition: Item val is inserted into the list and // an iterator to the newly inserted item is returned. void remove(const T& val); // Removes all items with value val from the list. // Precondition: None. // Postcondition: The list has no item with value val. iterator erase(iterator i); // Removes the item in the list pointed to by iterator i. // Precondition: The iterator must be initialized to // point to an element in the list. // Postcondition: Returns an iterator to the item // following the removed item. If the item removed is the // last item in the list, the iterator value will be the // same as the value returned by end(). iterator begin(); // Returns an iterator to the first item in the list. // Precondition: None. // Postcondition: If the list is empty, the iterator // value will be the same as the value returned by end(). iterator end(); // Returns an iterator value that can be used to test // whether the end of the list has been reached. // Precondition: None. // Postcondition: The iterator value for the end of the list is returned. // is returned void sort(); // Sorts elements according to the operator < and maintains the // relative order of equal elements. // Precondition: None. // Postcondition: The list is sorted in ascending order. } // end STL class list
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -