Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ STL source code analysis - iterator each container classification     - Use SVN to automatically deploy code under Apache (Server)

- Use rfkill soft-switching and Bluetooth wireless capabilities in Linux (Linux)

- Linux shared libraries .so file name and Dynamic Link (Linux)

- Examples of safety testing system notes for RedHat Linux (Linux)

- CV: Linux command displays the progress of the run command (Linux)

- How to write a new Git protocol (Linux)

- Teach you the Ubuntu Server enabled SSH multifactor authentication (Server)

- CentOS7 yum install third-party source EPEL (Linux)

- Nodejs complete installation instructions for Express (Linux)

- 10 useful Linux command Interview Questions and Answers (Linux)

- Upgrading to MySQL 5.7 partitioning problem solving (Database)

- Linux environment variable configuration and save places (Linux)

- CentOS 6.5 boot automatically mount the hard drive (Linux)

- C # / iOS / Android Universal Encryption and decryption (Programming)

- Cryptography development environment to build under Ubuntu (Linux)

- How to create a binary distribution with Bash (Linux)

- Install the Red Hat Container Development Kit on OSX (Server)

- Compile and install Ubuntu Linux 4.0.5 kernel, network and fix vmware kernel module compilation error (Linux)

- Ubuntu 15.04 / 14.04 install Ubuntu After Install 2.6 (Linux)

- Hutchison DG standby database CPU consumption reached bottleneck repair (Database)

 
         
  STL source code analysis - iterator each container classification
     
  Add Date : 2018-11-21      
         
         
         
  Five iterator as follows:

1, input iterator: read-only, one pass

As input iterator predefined implementations only istream_iterator and istreambuf_iterator, for reading from an input stream istream in. An input iterator for each element only once it has chosen to resolve, they can only move forward. A special constructor is defined beyond the end of the value. Always, input iterator can read the results of parsing (parse only once for each value), and then move forward.

2, the output iterator: write only, one pass

This is in addition to the input iterators, but instead of reading the write operation. Output iterator predefined implementations only ostream_iterator and ostreambuf_iterator, used to write data to an output stream ostream, there is generally a less used raw_storage_iterator. They parsed only once for each value written, and can only move forward. For output iterator, it is not used beyond the end of the value to the end of the concept. In short, the value of output iterator can write to parse (only parsed once for each value), and then move forward.

3, forward iterators: multiple read / write

Forward iterators contain both input and output iterator functions, plus you can also resolve many an iterator specified location, it can be a value for multiple read / write. As the name suggests, forward iterators can only move forward. Not the forward iterator predefined iterators.

4, bidirectional iterators: operator--

Bidirectional iterator has all the features the forward iteration. In addition it can be used and decrement operator-- backward move one position. Container from the list returned iterators are bidirectional.

5, random access iterators: similar to a pointer

Random access iterator bidirectional iterator has all the features, plus a pointer to all the functions (a pointer is a random access iterator), except that no kind of "empty (null)" iterators and null pointer corresponds. Basically it can be said, a random access iterator as a pointer that can carry out any operation, including the use of operator operator [] index, add a value to a pointer can move forward or backward a number of positions, or use a comparison between the iterator compare.

vector and deque offer is RandomAccessIterator, list is provided by iterators BidirectionalIterator, set and map is provided Bidirectional Iterator, hash_set and hash_map iterator is Forward Iterator. About the STL iterator iterator as follows:

Iterator category

Explanation

Input iterator

Read elements from the container. Input iterator can only be read into one element is moved forward again only supports input iterator algorithm, the same input iterator can traverse a sequence twice

Output iterator

Write element to the container. Output iterator can only move forward one at a time element. Output iterator algorithm supports only once, not twice unified output iterator to traverse a sequence

Forward iterators

Combination of input and output iterator iterator function, and retain the position in the container

Bidirectional iterators

Combination of forward and reverse iterator iterator function, support multi-pass algorithm

Random access iterators

Combination of bidirectional iterators functions and features direct access to any element of the container, you can skip forward any elements backwards

Iterator operations:

Each iterator can be carried out, including the operating table before an iterative can be carried out. By overloaded operators to achieve, and what action to support iterators can perform what operation is determined by the iterator overloaded operator nature of the operation of the iterator.

Iterator type of operation Type Description
All iterators

p ++

++ P

Post-increment iterator

Pre-increment iterator s's

Input iterator

* P

p = p1

p == p1

p! = p1

Dereferenced iterator, as a right value

An iterator assigned to another iterator

Compare iterators for equality

Compare iterator inequality

Output iterator

* P

p = p1

Dereferenced iterator, as lvalue

An iterator assigned to another iterator

Forward iterators

Provide all input and output iterator function

 

Bidirectional iterators

--p

p--

Pre-decrement iterator

Post-decrement iterator

Random access iterators

p + = i

p- = i

p + i

p-i

p [i]

p < p1

p < = p1

p> p1

p> = p1

Increment the iterator i bits

Decrement the iterator i bits

In the p bits plus i bit iterator

In the p bit down i bit iterator

Returns the p-bit elements departing from the i-th element reference

If the iterator p position before p1, returns true, false otherwise

p position returns true if the front or in the same position p1, and false otherwise

If the iterator p position after p1, returns true, false otherwise

p returns true if the position or behind the same position p1, and false otherwise

 Only order containers and associative containers support iterators traversal iterator each container supports the following categories:
Container supports iterator category container supports iterator category container supports iterator category
vector random access random access list bidirectional deque
bi-directional bi multiset set bidirectional map
multimap does not support two-way stack does not support queue
priority_queue not supported before hash_set forward to hash_map
     
         
         
         
  More:      
 
- To compile and install MySQL 5.7.7 RC under CentOS 7.1 (Database)
- Linux source code to install Apache and solutions to common errors (Server)
- Getting Started with Linux system to learn: How to compress JPEG images on the command line (Linux)
- Linux PXE unattended installation PXE-E32: TFTP OPen timeout the solution (Linux)
- Java objects are taking up much space (Programming)
- Android system source code and compile the kernel source code (Programming)
- rpm package specify the installation path (Linux)
- MySQL completely uninstall and install Configuring Character Sets under Linux (Database)
- CentOS 6.4 dial-up Raiders (Linux)
- Build their own recursive DNS server (Server)
- Java development specifications summary (Programming)
- Android design patterns - state mode (Programming)
- Security basics: simple analytical framework for Linux system firewall (Linux)
- CentOS RedHat YUM Source Extensions Supplement (including 32-bit, 64-bit) (Linux)
- Security matters and practical Linux System (Linux)
- Binary tree traversal algorithm summary (recursive and non-recursive) (Programming)
- To install the iNode client on UbuntuKylin 13.10 (Linux)
- Analysis JavaBean (Programming)
- Android WebView use layman (Programming)
- Java objects to garbage collection (Programming)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.