zoukankan      html  css  js  c++  java
  • 测试随笔功能

    1111

    啊啊啊啊

    =-、*-

    #include <stdlib.h>
    #include "list.h"
    
    // 创建节点
    Node* create_node(void* data)
    {
        Node* node = malloc(sizeof(Node));
        node->data = data;
        node->next = NULL;
        return node;
    }
    
    // 销毁节点
    void destory_node(Node* node)
    {
        free(node->data);
        free(node);
    }
    
    // 创建链表
    List* create_list(void)
    {
        List* list = malloc(sizeof(List));
        list->head = NULL;
        list->tail = NULL;
        list->size = 0;
        return list;
    }
    
    // 销毁链表
    void destory_list(List* list);
    // 尾添加
    void add_list(List* list,void* data)
    {
        Node* node = create_node(data);
        if(0 == list->size)
        {
            list->head = node;
            list->tail = node;
        }
        else
        {
            list->tail->next = node;
            list->tail = node;
        }
        list->size++;
    }
    
    // 删除
    bool del_list(List* list,void* cond,compar cmp)
    {
        Node* temp = list->head;
        if(cmp(cond,list->head->data))
        {
            list->head = temp->next;
            destory_node(temp);
            list->size--;
            return true;
        }
        while(NULL!=temp->next)
        {
            if(cmp(cond,temp->next->data))
            {
                Node* node = temp->next;
                temp->next = node->next;
                if(node == list->tail)
                {
                    list->tail = temp;
                }
                destory_node(node);
                list->size--;
                return true;
            }
            temp = temp->next;
        }
        return false;
    }
    
    // 查找
    void* find_list(List* list,void* cond,compar cmp);
    // 排序
    void sort_list(List* list,compar cmp);
    // 遍历
    void show_list(List* list,void (*show)(void* data))
    {
        for(Node* node=list->head; NULL!=node; node=node->next)
        {
            show(node->data);
        }
    }
  • 相关阅读:
    让层遮挡select(ie6下的问题)
    HTTP协议详解(真的很经典)
    网络编辑基础:对HTTP协议的头信息详解
    (OK) MIMP
    (OK) MIMP
    (OK) MIMP
    (OK)(OK) Android-x86-7.1.1/ kernel 4.4.62
    (OK)(OK) Android-x86-7.1.1/ kernel 4.4.62
    (OK) Android-x86-7.1.1/ kernel 4.4.62
    (OK)(OK) Android-x86-7.1.1/ kernel 4.4.62
  • 原文地址:https://www.cnblogs.com/ikaros-521/p/test.html
Copyright © 2011-2022 走看看