Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ C ++ containers     - To use iostat display I / O status under Linux (Linux)

- Python developer of time-saving method (Programming)

- Android thread mechanism --AsyncTask (Programming)

- Ubuntu 14.04 / 14.10 how to install FFmpeg 2.5.1 (Linux)

- Rman Oracle database backup and recovery plan (Database)

- rsync server set up (Server)

- Ubuntu 15.10 under Python + Apache + CGI fully configured (Server)

- How to view the Linux QPS (Linux)

- To install Google Chrome browser under Ubuntu 14.04 LTS (Linux)

- To create a problem by the statement date comparison of the difference between MySQL and Oracle (Database)

- Android components save state series - Activity (Programming)

- Linux initialization init systems - Systemd (Linux)

- Install Gnome Flashback Classic Desktop on Ubuntu 14.10 / Mint 7 (Linux)

- Linux log management make the system more secure (Linux)

- CentOS 7 Docker build private warehouse registry (Linux)

- httpd-2.4 feature (Server)

- Autojump: an advanced cd command in the Linux file system fast navigation (Linux)

- QBit development of micro-services (Server)

- Thinking in Java study notes - everything is an object (Programming)

- Tsunami-udp accelerated network transmission (Linux)

  C ++ containers
  Add Date : 2017-02-22      
  Container and container adapter

Container including vector, deque, list, map, multimap, set, multiset. Based deque container adapter includes the stack and queue, based on the priority_queue vector. stl string also implements the interface.

Because often you need to find the function interface container when writing C ++ programs, pretending this summary. Container and the newly introduced C ++ function is not introduced. Since the main reference: STL Containers and Container Adaptors

Sequence Container

Including vector, deque, list

Total function

ContainerType < T> c;
ContainerType < T> c (num);
ContainerType < T> c (num, val);
ContainerType < T> c (inIterBegin, inIterEnd);
// Copy constructor
ContainerType < T> c (otherLikeContainer);
ContainerType < T> c = otherLikeContainer;
Assignment constructor
c1 = c2
Comparison operation
c1 == c2
c1! = c2
c1 < c2 // element individually by comparison
c1 < = c2
c1> c2
c1> = c2
empty ()
size ()
max_size ()
resize (num, val = default)
Iterators and references
begin ()
end ()
rbegin ()
rend ()
front ()
back ()
Insert values
push_back (val)
insert (iter, val)
insert (iter, num, val)
insert (iter, inIterBegin, inIterEnd)
Assignment (replace all of the elements in the container)
assign (inIterBegin, inIterEnd)
assign (num, val)
Removing elements
pop_back ()
erase (iter)
erase (iterBegin, iterEnd)
clear ()
swap (otherLikeContainer)
get_allocator ()
Specific function

reserve (num)
capacity ()
list specific
merge (otherList) // merge in order of size, the two must be ordered
merge (otherList, binPred)
remove (val)
remove_if (unPred)
reverse ()
sort ()
sort (binPred)
splice (iter, otherList) // will otherList all elements to move at iter
splice (iter, otherList, otherIterBegin, otherIterEnd)
unique ()
unique (binPred)
vector and deque unique
at (index) // checks subscript range
operator [] (index)
deque and list specific
push_front (val)
pop_front ()
Container adapter

Including stack, queue, priority_queue

Total function

c1 = c2
empty ()
size ()
push (val)
pop ()
Specific function

queue-specific function
front ()
back ()
stack and functions specific to priority_queue
top ()
! =
< =
> =
Sequence container and container adapter function table

See The STL Sequential Containers and Container Adaptors,
and their Member Functions

Associative containers

It includes a map, multimap, set, multiset

Total function

c1 = c2
! =
< =
> =
empty () const
size () const
max_size ()
begin ()
end ()
rbegin ()
rend ()
Insert values
insert (p, val)
insert (start, end)
erase (someKey)
erase (iter)
erase (start, end)
clear ()
count (someKey)
find (someKey) // return iterator
lower_bound (someKey) // greater than or equal someKey iterator
upper_bound (someKey) // greater than someKey iterator
equal_range (someKey)
swap (otherLikeContainer)
get_allocator ()
// Function object key and val comparison
key_comp ()
value_comp ()
Specific function

In fact, there is no specific function, but these functions are slightly different interfaces

map / multimap specific constructor
ContainerType < keyType, ValueType> c;
ContainerType < KeyType, ValueType> c (inIterBegin, inIterEnd);
ContainerType < KeyType, ValueType> c (otherLikeContainer);
set / multiset specific constructor
ContainerType < T> c;
ContainerType < T> c (inIterBegin, inIterEnd);
ContainerType < T> c (otherLikeContainer);
map unique member functions
operator [someKey]
map / set unique member functions
// Return value pair < iterator, true / false (if already contains this value)>
insert (val)
multimap / multiset unique member functions
// Return iterator
insert (val)
Associative container function table

See The STL Associative Containers and their Member Functions


Including string, bitset and other types of containers


string s;
string s (c_string_value);
string s (char_array, size_type_count);
string s (string_value);
string s (string_value, size_type_index);
string s (string_value, size_type_index, size_type_count);
string s (size_type_count, char_value);
string s (input_iterator_start, input_iterator_end);
Take char
s [i]
s.at (i) // border checks
s.begin ()
s.end ()
s.rbegin ()
s.rend ()
append and assignment
operator + =
s.append (string_value)
s.append (c_string_value)
s.append (size_type_count, char_value)
s.append (c_string_value, size_type_count)
s.append (c_string_value, size_type_index, size_type_count)
s.append (first_input_iterator, last_input_iterator)
operator =
s.assign (string_value)
s.assign (c_string_value)
s.assign (size_type_count, char_value)
s.assign (c_string_value, size_type_count)
s.assign (c_string_value, size_type_index, size_type_count)
s.assign (start_input_iterator, end_input_iterator)
Converted to c-string
s.copy (char_array, size_type_count, size_type_index)
s.c_str () // Returns \ char array address zero-terminated array s all go, do not change
s.data () // Returns to \ char array address zero-terminated array s all go, do not change
s.substr (size_type_index)
s.substr (size_type_index, size_type_count)
Capacity and capacity adjustment
s.empty ()
s.capacity ()
s.length ()
s.size ()
s.max_size ()
s.reserve (size_type_value)
s.resize (size_type_value, char_value)
s.resize (size_type_value)
s.clear ()
s.erase () // delete all the characters
s.erase (size_type_index)
s.erase (size_type_index, size_type_count)
s.erase (iterator_position)
s.erase (first_iterator, last_iterator)
// Find all of the index values ​​are returned, if found, return string :: npos
// Find the char
s.find (char_value)
s.find (char_value, size_type_index)
s.rfind (char_value)
s.rfind (char_value, size_type_index)
// Find string
s.find (string_value)
s.find (string_value, size_type_index) // Find the index at
// Find forward from the rear
s.rfind (string_value)
s.rfind (string_value, size_type_index)
// Find cstring
s.find (c_string_value, size_type_index, size_type_count)
s.rfind (c_string_value, size_type_index, size_type_count)
s.find_first_of (char_value)
s.find_first_of (char_value, size_type_index)
s.find_first_not_of (char_value)
s.find_first_not_of (char_value, size_type_index)
// Find the char / absence of the string, and returns the next subscript
s.find_first_of (string_value)
s.find_first_of (string_value, size_type_index)
s.find_first_not_of (string_value)
s.find_first_not_of (string_value, size_type_index)
s.find_first_of (c_string_value, size_type_index, size_type_count)
s.find_first_not_of (string_value, size_type_index, size_type_count)
s.find_last_of (char_value)
s.find_last_of (char_value, size_type_index)
s.find_last_not_of (char_value)
s.find_last_not_of (char_value, size_type_index)
s.find_last_of (string_value)
s.find_last_of (string_value, size_type_index)
s.find_last_not_of (string_value)
s.find_last_not_of (string_value, size_type_index)
s.find_last_of (c_string_value, size_type_index, size_type_count)
s.find_last_not_of (string_value, size_type_index, size_type_count)
Insert values
s.insert (size_type_index, string_variable)
s.insert (size_type_index, c_string_value)
s.insert (size_type_index1, string_variable, size_type_index2, size_type_count)
s.insert (size_type_index, c_string_value, size_type_count)
s.insert (size_type_index, size_type_count, char_value) // c ++ in the function parameter is always count before val
s.insert (iterator_position, size_type_count, char_value)
s.insert (iterator_position, char_value)
s.insert (iterator_position, input_iterator_first, input_iterator_last)
s.push_back (char_value)
Character / string replacement
s.replace (size_type_index, size_type_count, string_value)
s.replace (iterator_first, iterator_last, string_value
s.replace (size_type_index1, size_type_count1, string_value,
        size_type_index2, size_type_count2)
s.replace (size_type_index, size_type_count, c_string_value)
s.replace (iterator_first, iterator_last, c_string_value)
s.replace (size_type_index, size_type_count1,
        c_string_value, size_type_count2)
s.replace (iterator_first, iterator_last,
        c_string_value, size_type_count)
s.replace (size_type_index, size_type_count1,
        size_type_count2, char_value)
s.replace (iterator_first, iterator_last,
        size_type_count, char_value)
s.replace (iterator_first, iterator_last,
        input_iterator_start, input_iterator_end)
// ==,! =, < ,>, < =,> = Already overloaded
// Compare the return value int: s-other
s.compare (string_value)
s.compare (size_type_index, size_type_count, string_value)
s.compare (size_type_index1, size_type_count1, string_value,
        size_type_index2, size_type_count2)
s.compare (c_string_value)
s.compare (size_type_index, size_type_count, c_string_value)
s.compare (size_type_index, size_type_count1,
        c_string_value, size_type_count2)
Other functions
s.swap (string_variable)
// The following three non-member functions
swap (string_variable1, string_variable2)
getline (inStream, string_variable)
// String results do not include delimiter
getline (inStream, string_variable, char_delimiter_value)
- Mac OS X system setup Google Go language development environment configuration tool Sublime Text 2 (Linux)
- Linux check disk parameters trapping lack amendments (Linux)
- Detailed PHP code optimization [section] (explain reasons) (Programming)
- Source MongoDB 3.2.1 installed on CentOS6.5 (Database)
- Ubuntu 14.04 set auto sleep time (Linux)
- Oracle10g 64-bit installation solution in Windows 2008 Server R2 (Database)
- Install Ubuntu open source drawing program MyPaint 1.2.0 (Linux)
- MySQL replication master and slave structure built (Database)
- Performance Optimization: Using Ramlog transfer log files to memory (Linux)
- Boost-- time and date - (1) timer library introduction (Programming)
- Use GNU / Linux broadcasting of television programs (Linux)
- Oracle GoldenGate tutorial Second, configure and use (Database)
- MySQL monitoring tool -Innotop (Database)
- CentOS7 installation performance monitoring system (Server)
- Windows 7 hard disk installation notes Debian (Linux)
- Java heap (Heap) and stack difference (Programming)
- Install Java 8 on Ubuntu using PPA (Linux)
- 3 ways to create a lightweight, durable system of Ubuntu Linux USB disk (Linux)
- Solve ORA-01012: not logged on (Database)
- VMware virtual machine to install CentOS 6.2 (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.