C++的一个好库。。。现在很流行

源代码在线查看: sort.rst

软件大小: 21075 K
上传用户: lyyfengyutongzh
关键词:
下载地址: 免注册下载 普通下载 VIP

相关代码

				.. Algorithms/Transformation Algorithms//sort |95
				
				sort
				====
				
				Synopsis
				--------
				
				.. parsed-literal::
				    
				    template<
				          typename Seq
				        , typename Pred = less
				        , typename In = |unspecified|
				        >
				    struct sort
				    {
				        typedef |unspecified| type;
				    };
				
				
				Description
				-----------
				
				Returns a new sequence of all elements in the range |begin/end| sorted according
				to the ordering relation ``Pred``. 
				
				|transformation algorithm disclaimer|
				
				
				Header
				------
				
				.. parsed-literal::
				    
				    #include 
				
				
				Model of
				--------
				
				|Reversible Algorithm|
				
				
				Parameters
				----------
				
				+-------------------+-----------------------------------+-------------------------------+
				| Parameter         | Requirement                       | Description                   |
				+===================+===================================+===============================+
				| ``Seq``           | |Forward Sequence|                | An original sequence.         |
				+-------------------+-----------------------------------+-------------------------------+
				| ``Pred``          | Binary |Lambda Expression|        | An ordering relation.         |
				+-------------------+-----------------------------------+-------------------------------+
				| ``In``            | |Inserter|                        | An inserter.                  |
				+-------------------+-----------------------------------+-------------------------------+
				
				
				Expression semantics
				--------------------
				
				|Semantics disclaimer...| |Reversible Algorithm|.
				
				For any |Forward Sequence| ``s``, a binary |Lambda Expression| ``pred``, and an 
				|Inserter| ``in``:
				
				
				.. parsed-literal::
				
				    typedef sort::type r;
				
				:Return type:
				    A type.
				    
				:Semantics:
				    If ``size::value 				
				    .. parsed-literal::
				
				        typedef copy::type r;
				    
				    
				    otherwise equivalent to 
				    
				    .. parsed-literal::
				
				        typedef back_inserter< vector > aux_in;
				        typedef lambda::type p;
				
				        typedef begin::type pivot;
				        typedef partition<
				              iterator_range< next::type, end::type >
				            , apply_wrap2
				            , aux_in
				            , aux_in
				            >::type partitioned;
				
				        typedef sort::type part1;
				        typedef sort::type part2;
				        
				        typedef copy<
				              joint_view< 
				                  joint_view >
				                , part2
				                >
				            , in
				            >::type r;
				
				
				Complexity
				----------
				
				Average *O(n log(n))* where *n* == ``size::value``, quadratic at worst.
				
				Example
				-------
				
				.. parsed-literal::
				    
				    typedef vector_c numbers;
				    typedef vector_c expected;
				    typedef sort::type result;
				
				    BOOST_MPL_ASSERT(( equal< result, expected, equal_to > ));
				
				
				See also
				--------
				
				|Transformation Algorithms|, |Reversible Algorithm|, |partition|
							

相关资源