资源简介

libcstl是使用C语言编写的一个通用的数据结构和常用的算法库,它模仿SGI STL的接口和实现,支持vector,list,deque等等常用的数据结构,同时还支持排序,查找,划分等常用的算法,此外libcstl也包含迭 代器的类型,它作为容器和算法之间的桥梁。libcstl为C语言编程中的数据管理提供了便利。

资源截图

代码片段和文件信息

/*
 *  The implementation of algorithm.
 *  Copyright (C)  2008200920102011  Wangbo
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not write to the Free Software
 *  Foundation Inc. 51 Franklin Street Fifth Floor Boston MA  02110-1301  USA
 *
 *  Author e-mail: activesys.wb@gmail.com
 *                 activesys@sina.com.cn
 */

/** include section **/
#include 
#include 
#include 
#include 
#include 
#include 

#include se.h>
#include se_private.h>
#include 

#include 
#include 

/** local constant declaration and local macro section **/
#define _CSTL_SORT_THRESHOLD  16 /* the threshold of insert sort and quick sort */

/** local data type declaration and local struct union enum section **/

/** local function prototype section **/
/*
 * Partition with bidirectional_iterator_t.
 */
static bidirectional_iterator_t _partition_biditer(
    bidirectional_iterator_t t_first bidirectional_iterator_t t_last
    unary_function_t t_unary_op);

/*
 * Rotates the elements in the range [t_first t_last).
 */
static void _rotate_forward(
    forward_iterator_t t_first
    forward_iterator_t t_middle
    forward_iterator_t t_last);

/*
 * The implement of insertion sort.
 */
static void _insertion_sort_if(
    random_access_iterator_t t_first random_access_iterator_t t_last
    binary_function_t t_binary_op char* pc_value);

/*
 * Return the median of three random_access_iterator_t
 */
static random_access_iterator_t _median_of_three_if(
    random_access_iterator_t t_first
    random_access_iterator_t t_middle
    random_access_iterator_t t_last
    binary_function_t t_binary_op);

/*
 * Compute the logarithm of t_n.
 */
static size_t _lg(size_t t_n);

/*
 * The implement of intro sort.
 */
static void _intro_sort_if(
    random_access_iterator_t t_first random_access_iterator_t t_last
    binary_function_t t_binary_op size_t t_depth char* pc_value);

/** exported global variable definition section **/

/** local global variable definition section **/

/** exported function implementation section **/
output_iterator_t algo_set_union(
    input_iterator_t t_first1 input_iterator_t t_last1
    input_iterator_t t_first2 input_iterator_t t_last2
    o

评论

共有 条评论