We learn together
common interface
string class common structure:
Function name | Function Description |
---|---|
string() | Configuration empty string class object, i.e., an empty string |
string(const char* s) | Construct with C-string string class object |
string(size_t n, char c) | string class object containing n characters c |
string(const string&s) | Copy constructor |
void Teststring()
{
string s1; // 构造空的string类对象s1
string s2("hello bit"); // 用C格式字符串构造string类对象s2
string s3(s2); // 拷贝构造s3
}
Common vector class constructor:
Function name | Function Description |
---|---|
vector() | No-argument constructor |
vector(size_type n, const value_type& val = value_type()) | Constructs and initializes the n val |
vector (const vector& x); | Copy constructor |
vector (InputIterator first, InputIterator last); | Using an iterator initialized structure |
std::vector<int> first;
std::vector<int> second (4,100);
std::vector<int> fourth (third);
std::vector<int> third (second.begin(),second.end());
list common class constructor:
Column 1 | Column 2 |
---|---|
list() | Construction empty list |
list (size_type n, const value_type& val = value_type()) | the configuration list contains n elements to val |
list (const list& x) | Copy constructor |
list (InputIterator first, InputIterator last) | Elemental configuration list [first, last) interval of |
std::list<int> l1;
std::list<int> l2 (4,100);
std::list<int> l4 (l3);
std::list<int> l3 (l2.begin(), l2.end());
Iterator operation
string, vector, list operation exactly three Iterative
Function name | Function Description |
---|---|
begin | The iterators return to the beginning |
end | Iterator will return to the end |
rbegin | The reverse iterator returned to the reverse start |
makes | The reverse iterator to return to the reverse end |
Space capacity operating
string, the operation of space vector type, length () function is a unique string class
Function name | Function Description |
---|---|
size/length | Returns a string length of valid characters |
capacity | Returns the total size of space |
max_size | On-line storage for the number of elements, usually due to the address space determined |
empty | Detecting the release of the string is empty string is returned true, false otherwise |
clear | Empty effective character |
reserve | Reserve space for the string |
resize | The number of the valid characters into n, the extra space is filled with character c |
Operation of the space capacity list class:
Function name | Function Description |
---|---|
size | Returns a string length of valid characters |
capacity | Returns the total size of space |
max_size | On-line storage for the number of elements, usually due to the address space determined |
Modify elements operating
string, vector, list common function to operate three classes
Function name | Function Description |
---|---|
push_back | At the end of the additional element |
pop_back | Delete the last element |
insert | Insert elements |
erase | Removing elements |
swap | Switching element |
Unique string operation
Function name | Function Description |
---|---|
operator+= | Appending the string after the string |
list category unique operation
Function name | Function Description |
---|---|
push_front | Head plug |
pop_front | Head deleted |
vector, list a total function
Function name | Function Description |
---|---|
clear | Empty contents |
Unique operation
for each type of template has its own unique number manipulation functions
such as: function string class c_str etc.
and some operations, such as:
List class unique (), remove (), remove_if (), sort (), reverse ( )
String class find (), copy () function, etc. Although the STL is unique, but the algorithm header file (the header file is much stronger than you imagine oh O ( ^ @ ^ ) O) in They are involved, which means as long as the use of get, reverse () can be used to target string class