SGI-STL abbreviated (XI) - adapter (containers, iterators, functor)

Adapters (adapters): 

    similar to the design mode of adaptation on the concept, here in the STL adapter combination of components, flexible use plays an important role. 
    STL adapter are: container adapter, iterator adapter, the adapter functor 
    
container adapter: 
    
    queue (FIFO), stack (last-out), The priority_queue (priority queues) adapter, i.e. _Sequence sequence of the template parameters queue and the stack the default type is the deque <T> (deque), 
    of course, the adapter may be necessary to meet other container may also be an interface, so that these can be considered as a sequence template _Sequence wrapper container. 

Iterator adapter: 
    
    INSERT insert iterator Iterator (by overloading operator = , i.e. assignments of the insert element), mainly in the following packaging iterator: 
        back_insert_iterator (call push_back container insert); 
        front_insert_iterator (call container inserted push_front ); 
        insert_iterator (call container insert is inserted after the specified location iterator); 
        
        corresponding to the three or more generated iterator convenience functions: back_inserter, front_insert, Inserter; 
    
    reverse iterator iterator reversal (ie, the original operator ++ goes back operation, operator- becomes forward operation) 
        a reverse_iterator reversed iterator class provides the basic reversal iterations (internal reference comprises an iterator iterator, iterator can be considered to reverse the packaging container iterator); 
        in addition rbegin portion of the container () , rend () returns an iterator containing respectively tail reversing header iterator iterator position. 
    
    iostream iterator Iterator IO streams (iostream object bound to the iterator, a data stream can easily operate the operation iterator object) 
        essentially maintains internal iterator IO stream a stream object stream, when performed on the input iterator object or when the output operation, i.e., call transfer operation to the stream object stream. 
        istream_iterator packaging an istream; an ostream_iterator packaging ostream object. 
    

Functor adapter: 
    
    can achieve unlimited adaptation (package) (also can be packaged with a functor functor), by binding, combinations and modifications may implement various complex expressions. 
    Furthermore, an adaptation of the object, should be adapted, but also means one element for an inheritance unary_function functor, binary functor inherited from a binary_function required, 
    but should the member function to mem_fun packaging process, generally functions to be ptr_fun packaging process. In other words, if adaptable, you can achieve unlimited package. 
    
    Common functor adapter: 
        bind1st, bind2nd, Notl, NOT2, compose1, compose2, ptr_fun, mem_fun, mem_fun_ref, mem_fun1, mem_fun1_ref like.
    

 

Guess you like

Origin www.cnblogs.com/haomiao/p/11666283.html