• 链表和队列的非正式的抽象定义


    1.类型名:简单链表

    2.类型属性:可以存储一系列项

    3.类型操作:初始化链表为空

                                 确定链表为空

                                 确定链表已满

                                 确定链表中的项数

                                 在链表末尾添加项

                                 遍历链表,处理链表中的项

                                 清空链表

    list.h的组织形式(代码):

    #ifndef LIST_H_
    #define LIST_H_
    #include<stdbool.h>
    #define TSIZE 45
    struct film
    {
      char title[TSIZE];
      int rating;
    };
    typedef struct film Item;
    typedef struct node
    {
      Item item;
      struct node * next;
    }Node,* List;
    void InitalizeList(List * plist);
    bool ListIsEmpty(const List *plist);
    bool ListIsFull(const List *plist);
    unsigned int ListItemCount(const List *plist);
    bool AddItem(Item item,List * plist);
    void Traverse(const List *plist,void(*pfun)(Item item));
    void EmptyTheList(List * plist);
    #endif

    1.类型名:队列

    2.类型属性:可以存储一系列的项

    3.类型操作:初始化队列为空

                                 确定队列为空

                                 确定队列已满

                                 确定队列中的项数

                                 在队列末尾添加项

                                 在队列开头删除或者恢复项

                                 清空队列

    queue.h组织形式:

    /*queue.h -- Queue的接口*/
    #ifndef _QUEUE_H_
    #define _QUEUE_H_
    #include <stdio.h>
    #include <stdbool.h>
    //在这里插入Item类型的定义,例如typedef int Item;//用于use_q.c;
    typedef int Item;
    #define MAXQUEUE 10

    typedef struct node
    {
      Item item;
      struct node * next;
    }Node;
    typedef struct Queue
    {
      Node * front;
      Node * rear;
      int items;
    }Queue;
    void InitalizeListQueue(Queue * pq);
    bool QueueIsFull(const Queue * pq);
    bool QueueIsEmpty(const Queue *pq);
    int QueueItemCount(const Queue * pq);
    bool EnQueue(Item item,Queue * pq);
    bool DeQueue(Item *pitem,Queue *pq);
    void EmptyTheQueue(Queue *pq);
    #endif
  • 相关阅读:
    CodeBlocks下载与安装教程
    Delphi 资源管理器套件
    做了一个 62 进制的简单实现
    关于 TRegEx.Split()
    Delphi 的链式代码
    在Linux上编译dotnet cli的源代码生成.NET Core SDK的安装包
    尝试解决在构造函数中同步调用Dns.GetHostAddressesAsync()引起的线程死锁
    .NET Core中遇到奇怪的线程死锁问题:内存与线程数不停地增长
    将asp.net core站点发布到IIS上遇到的问题
    .NET Core 构建配置文件从 project.json 到 .csproj
  • 原文地址:https://www.cnblogs.com/shiheyuanfang/p/13270195.html
Copyright © 2020-2023  润新知