亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? list.c

?? 一些常用的數據結構庫
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * List Abstract Data Type * Copyright (C) 1997 Kaz Kylheku <kaz@ashi.footprints.net> * * Free Software License: * * All rights are reserved by the author, with the following exceptions: * Permission is granted to freely reproduce and distribute this software, * possibly in exchange for a fee, provided that this copyright notice appears * intact. Permission is also granted to adapt this software to produce * derivative works, as long as the modified versions carry this copyright * notice and additional notices stating that the work has been modified. * This source code may be translated into executable form and incorporated * into proprietary software; there is no requirement for such software to * contain a copyright notice related to this source. * * $Id: list.c,v 1.19.2.1 2000/04/17 01:07:21 kaz Exp $ * $Name: kazlib_1_20 $ */#include <stdlib.h>#include <stddef.h>#include <assert.h>#define LIST_IMPLEMENTATION#include "list.h"#define next list_next#define prev list_prev#define data list_data#define pool list_pool#define fre list_free#define size list_size#define nilnode list_nilnode#define nodecount list_nodecount#define maxcount list_maxcount#define list_nil(L)		(&(L)->nilnode)#define list_first_priv(L)	((L)->nilnode.next)#define list_last_priv(L)	((L)->nilnode.prev)#define lnode_next(N)		((N)->next)#define lnode_prev(N)		((N)->prev)#ifdef KAZLIB_RCSIDstatic const char rcsid[] = "$Id: list.c,v 1.19.2.1 2000/04/17 01:07:21 kaz Exp $";#endif/* * Initialize a list object supplied by the client such that it becomes a valid * empty list. If the list is to be ``unbounded'', the maxcount should be * specified as LISTCOUNT_T_MAX, or, alternately, as -1. The value zero * is not permitted. */list_t *list_init(list_t *list, listcount_t maxcount){    assert (maxcount != 0);    list->nilnode.next = &list->nilnode;    list->nilnode.prev = &list->nilnode;    list->nodecount = 0;    list->maxcount = maxcount;    return list;}/* * Dynamically allocate a list object using malloc(), and initialize it so that * it is a valid empty list. If the list is to be ``unbounded'', the maxcount * should be specified as LISTCOUNT_T_MAX, or, alternately, as -1. */list_t *list_create(listcount_t maxcount){    list_t *new = malloc(sizeof *new);    if (new) {	assert (maxcount != 0);	new->nilnode.next = &new->nilnode;	new->nilnode.prev = &new->nilnode;	new->nodecount = 0;	new->maxcount = maxcount;    }    return new;}/* * Destroy a dynamically allocated list object. * The client must remove the nodes first. */void list_destroy(list_t *list){    assert (list_isempty(list));    free(list);}/* * Free all of the nodes of a list. The list must contain only  * dynamically allocated nodes. After this call, the list * is empty. */void list_destroy_nodes(list_t *list){    lnode_t *lnode = list_first_priv(list), *nil = list_nil(list), *tmp;    while (lnode != nil) {	tmp = lnode->next;	lnode->next = NULL;	lnode->prev = NULL;	lnode_destroy(lnode);	lnode = tmp;    }    list_init(list, list->maxcount);}/* * Return all of the nodes of a list to a node pool. The nodes in * the list must all have come from the same pool. */void list_return_nodes(list_t *list, lnodepool_t *pool){    lnode_t *lnode = list_first_priv(list), *tmp, *nil = list_nil(list);    while (lnode != nil) {	tmp = lnode->next;	lnode->next = NULL;	lnode->prev = NULL;	lnode_return(pool, lnode);	lnode = tmp;    }    list_init(list, list->maxcount);}/* * Insert the node ``new'' into the list immediately after ``this'' node. */void list_ins_after(list_t *list, lnode_t *new, lnode_t *this){    lnode_t *that = this->next;    assert (new != NULL);    assert (!list_contains(list, new));    assert (!lnode_is_in_a_list(new));    assert (this == list_nil(list) || list_contains(list, this));    assert (list->nodecount + 1 > list->nodecount);    new->prev = this;    new->next = that;    that->prev = new;    this->next = new;    list->nodecount++;    assert (list->nodecount <= list->maxcount);}/* * Insert the node ``new'' into the list immediately before ``this'' node. */void list_ins_before(list_t *list, lnode_t *new, lnode_t *this){    lnode_t *that = this->prev;    assert (new != NULL);    assert (!list_contains(list, new));    assert (!lnode_is_in_a_list(new));    assert (this == list_nil(list) || list_contains(list, this));    assert (list->nodecount + 1 > list->nodecount);    new->next = this;    new->prev = that;    that->next = new;    this->prev = new;    list->nodecount++;    assert (list->nodecount <= list->maxcount);}/* * Delete the given node from the list. */lnode_t *list_delete(list_t *list, lnode_t *del){    lnode_t *next = del->next;    lnode_t *prev = del->prev;    assert (list_contains(list, del));    prev->next = next;    next->prev = prev;    list->nodecount--;    del->next = del->prev = NULL;    return del;}/* * For each node in the list, execute the given function. The list, * current node and the given context pointer are passed on each * call to the function. */void list_process(list_t *list, void *context,	void (* function)(list_t *list, lnode_t *lnode, void *context)){    lnode_t *node = list_first_priv(list), *next, *nil = list_nil(list);    while (node != nil) {	/* check for callback function deleting	*/	/* the next node from under us		*/	assert (list_contains(list, node));	next = node->next;	function(list, node, context);	node = next;    }}/* * Dynamically allocate a list node and assign it the given piece of data. */lnode_t *lnode_create(void *data){    lnode_t *new = malloc(sizeof *new);    if (new) {	new->data = data;	new->next = NULL;	new->prev = NULL;    }    return new;}/* * Initialize a user-supplied lnode. */lnode_t *lnode_init(lnode_t *lnode, void *data){    lnode->data = data;    lnode->next = NULL;    lnode->prev = NULL;    return lnode;}/* * Destroy a dynamically allocated node. */void lnode_destroy(lnode_t *lnode){    assert (!lnode_is_in_a_list(lnode));    free(lnode);}/* * Initialize a node pool object to use a user-supplied set of nodes. * The ``nodes'' pointer refers to an array of lnode_t objects, containing * ``n'' elements. */lnodepool_t *lnode_pool_init(lnodepool_t *pool, lnode_t *nodes, listcount_t n){    listcount_t i;    assert (n != 0);    pool->pool = nodes;    pool->fre = nodes;    pool->size = n;    for (i = 0; i < n - 1; i++) {	nodes[i].next = nodes + i + 1;    }    nodes[i].next = NULL;    nodes[i].prev = nodes;	/* to make sure node is marked ``on list'' */    return pool;}/* * Create a dynamically allocated pool of n nodes. */lnodepool_t *lnode_pool_create(listcount_t n){    lnodepool_t *pool;    lnode_t *nodes;    assert (n != 0);    pool = malloc(sizeof *pool);    if (!pool)	return NULL;    nodes = malloc(n * sizeof *nodes);    if (!nodes) {	free(pool);	return NULL;    }    lnode_pool_init(pool, nodes, n);    return pool;}/* * Determine whether the given pool is from this pool. */int lnode_pool_isfrom(lnodepool_t *pool, lnode_t *node){    listcount_t i;    /* this is carefully coded this way because ANSI C forbids pointers       to different objects from being subtracted or compared other       than for exact equality */    for (i = 0; i < pool->size; i++) {	if (pool->pool + i == node)	    return 1;    }    return 0;}/* * Destroy a dynamically allocated pool of nodes. */void lnode_pool_destroy(lnodepool_t *p){    free(p->pool);    free(p);}/* * Borrow a node from a node pool. Returns a null pointer if the pool * is exhausted.  */lnode_t *lnode_borrow(lnodepool_t *pool, void *data){    lnode_t *new = pool->fre;    if (new) {	pool->fre = new->next;	new->data = data;	new->next = NULL;	new->prev = NULL;    }    return new;}/* * Return a node to a node pool. A node must be returned to the pool * from which it came. */void lnode_return(lnodepool_t *pool, lnode_t *node){    assert (lnode_pool_isfrom(pool, node));    assert (!lnode_is_in_a_list(node));    node->next = pool->fre;    node->prev = node;    pool->fre = node;}/* * Determine whether the given list contains the given node. * According to this function, a list does not contain its nilnode. */int list_contains(list_t *list, lnode_t *node){    lnode_t *n, *nil = list_nil(list);    for (n = list_first_priv(list); n != nil; n = lnode_next(n)) {	if (node == n)	    return 1;    }    return 0;}/* * A more generalized variant of list_transfer. This one removes a * ``slice'' from the source list and appends it to the destination * list. */void list_extract(list_t *dest, list_t *source, lnode_t *first, lnode_t *last){    listcount_t moved = 1;    assert (first == NULL || list_contains(source, first));    assert (last == NULL || list_contains(source, last));    if (first == NULL || last == NULL)	return;    /* adjust the destination list so that the slice is spliced out */    first->prev->next = last->next;    last->next->prev = first->prev;    /* graft the splice at the end of the dest list */    last->next = &dest->nilnode;    first->prev = dest->nilnode.prev;    dest->nilnode.prev->next = first;    dest->nilnode.prev = last;    while (first != last) {	first = first->next;	assert (first != list_nil(source));	/* oops, last before first! */	moved++;    }        /* assert no overflows */    assert (source->nodecount - moved <= source->nodecount);    assert (dest->nodecount + moved >= dest->nodecount);    /* assert no weirdness */    assert (moved <= source->nodecount);    source->nodecount -= moved;    dest->nodecount += moved;    /* assert list sanity */    assert (list_verify(source));    assert (list_verify(dest));}/* * Split off a trailing sequence of nodes from the source list and relocate * them to the tail of the destination list. The trailing sequence begins * with node ``first'' and terminates with the last node of the source * list. The nodes are added to the end of the new list in their original * order. */void list_transfer(list_t *dest, list_t *source, lnode_t *first){    listcount_t moved = 1;    lnode_t *last;    assert (first == NULL || list_contains(source, first));    if (first == NULL)	return;    last = source->nilnode.prev;    source->nilnode.prev = first->prev;    first->prev->next = &source->nilnode;    last->next = &dest->nilnode;    first->prev = dest->nilnode.prev;    dest->nilnode.prev->next = first;    dest->nilnode.prev = last;    while (first != last) {	first = first->next;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美亚一区二区| 国产午夜亚洲精品理论片色戒| 精品久久久久一区| 久久久精品免费网站| 亚洲一卡二卡三卡四卡无卡久久| 欧美精品一区二| 亚洲色图.com| 国产成人综合网| 69堂成人精品免费视频| 亚洲男女一区二区三区| 国产成人免费在线视频| 欧美伊人久久大香线蕉综合69| 在线欧美一区二区| 亚洲国产精品传媒在线观看| 午夜精品福利一区二区三区av| 亚洲在线免费播放| 91网站最新地址| 国产欧美日韩精品一区| 国内一区二区在线| 666欧美在线视频| 亚洲美女区一区| av影院午夜一区| 久久在线观看免费| 久久99精品久久久久| 欧美一区二区三区不卡| 亚洲一区二区五区| 色综合久久九月婷婷色综合| 夜夜揉揉日日人人青青一国产精品| 一区二区三区欧美日| 成人av电影在线| 国产亚洲成av人在线观看导航| 国产精品狼人久久影院观看方式| 亚洲天堂精品视频| 成人深夜在线观看| 国产精品网站一区| av电影一区二区| 中文字幕精品一区二区三区精品| 怡红院av一区二区三区| 91黄色激情网站| 亚洲精品视频免费看| 在线观看亚洲一区| 亚洲综合精品久久| 欧美乱妇15p| 日韩电影在线一区| 日韩美女视频在线| 国产在线国偷精品产拍免费yy| 国产精品影视天天线| 国产人妖乱国产精品人妖| 大尺度一区二区| 国产精品日日摸夜夜摸av| 99久久久免费精品国产一区二区| 538在线一区二区精品国产| 强制捆绑调教一区二区| 日韩亚洲欧美在线观看| 国产+成+人+亚洲欧洲自线| 亚洲图片激情小说| 欧美美女喷水视频| 久久电影网电视剧免费观看| 久久精品亚洲麻豆av一区二区| 亚洲va韩国va欧美va精品| 91精品国产全国免费观看| 国产精品一区二区x88av| 亚洲视频一区在线观看| 欧美日韩亚洲综合在线| 欧美aaaaaa午夜精品| 日本一区二区在线不卡| 欧美视频第二页| 精品一二线国产| 亚洲欧美乱综合| 欧美精品一区二区三区一线天视频| 视频一区二区三区入口| 日本一区二区三区视频视频| 色诱视频网站一区| 国内精品伊人久久久久av一坑 | 最近日韩中文字幕| 欧美中文字幕一区二区三区| 青青草91视频| 亚洲免费观看高清在线观看| 欧美大片一区二区| 一本到高清视频免费精品| 美日韩一级片在线观看| 国产精品国产自产拍高清av| 日韩欧美国产综合在线一区二区三区| 亚洲乱码国产乱码精品精的特点| 成人av网站免费观看| 秋霞成人午夜伦在线观看| 综合激情成人伊人| 久久综合九色综合久久久精品综合| 热久久一区二区| 亚洲激情网站免费观看| 国产亚洲精品aa午夜观看| 91精品欧美一区二区三区综合在| 亚洲国产成人高清精品| 国产亚洲福利社区一区| 欧美一区二区三区小说| 欧洲精品在线观看| 97久久精品人人做人人爽50路| 中文字幕在线免费不卡| 精品国产欧美一区二区| 欧美精品一卡两卡| 色婷婷av一区二区三区软件| 国产成人亚洲综合a∨猫咪| 蜜桃视频在线观看一区二区| 亚洲国产日韩综合久久精品| 亚洲日本在线观看| 国产精品久久久久一区二区三区共| 色婷婷综合激情| 91丨porny丨最新| 国产999精品久久| 亚洲国产精品久久艾草纯爱| 中文字幕日韩一区| 综合自拍亚洲综合图不卡区| 国产日产欧美精品一区二区三区| 欧美精品在线观看播放| 欧美日韩国产综合一区二区三区| 91成人在线精品| 欧美视频三区在线播放| 欧美特级限制片免费在线观看| 91国产视频在线观看| 97久久久精品综合88久久| 色婷婷狠狠综合| 在线日韩国产精品| 欧美人狂配大交3d怪物一区| 欧美日本韩国一区| 欧美成人官网二区| 国产网红主播福利一区二区| 国产欧美一区二区三区沐欲| 国产日本欧洲亚洲| 亚洲蜜臀av乱码久久精品 | 亚洲成人激情社区| 日韩国产精品91| 国产精品一线二线三线| 成人午夜电影网站| 91美女片黄在线观看91美女| 在线视频你懂得一区| 91精品国产麻豆| 久久青草欧美一区二区三区| 亚洲国产电影在线观看| 一区二区三区四区不卡视频| 亚洲国产精品一区二区久久恐怖片 | 91免费视频网| 色欧美88888久久久久久影院| 91丨porny丨蝌蚪视频| 欧美日韩亚洲另类| 26uuu成人网一区二区三区| 日本一区二区成人在线| 亚洲成人动漫在线观看| 国产一区二区三区免费| 一本一道久久a久久精品综合蜜臀 一本一道综合狠狠老 | 久久亚洲精品国产精品紫薇| 国产色综合久久| 亚洲夂夂婷婷色拍ww47| 久久99精品国产.久久久久久| 成人午夜私人影院| 欧美日韩黄视频| 国产精品网曝门| 天堂一区二区在线| 成人一区二区三区中文字幕| 欧美三级在线播放| 欧美国产日本韩| 首页国产丝袜综合| 成人av资源在线观看| 91精品国产欧美一区二区成人| 中文字幕一区免费在线观看| 免费成人你懂的| 91行情网站电视在线观看高清版| 精品免费一区二区三区| 亚洲国产成人91porn| aaa亚洲精品| 欧美精品一区二区三区高清aⅴ | 日本不卡免费在线视频| 91麻豆产精品久久久久久| www国产精品av| 亚洲第一会所有码转帖| 91免费看片在线观看| 久久久精品2019中文字幕之3| 五月婷婷久久综合| 欧美在线一二三| 国产精品久久久久久久久果冻传媒 | 精品国产欧美一区二区| 亚洲国产综合在线| 成人永久aaa| 337p粉嫩大胆噜噜噜噜噜91av| 日韩精品成人一区二区三区| 一本色道久久综合狠狠躁的推荐| 国产欧美va欧美不卡在线| 肉丝袜脚交视频一区二区| 在线观看亚洲精品| 亚洲欧美日韩久久| 91蜜桃网址入口| 亚洲人午夜精品天堂一二香蕉| 成人av电影在线| 国产精品久久毛片av大全日韩| 国产·精品毛片| 国产情人综合久久777777| 国产91在线观看| 国产精品乱人伦| 成人av在线播放网址| 国产精品国产精品国产专区不蜜| 成人午夜激情在线|