文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>在C语言中引入类的概念

在C语言中引入类的概念

时间:2010-11-02  来源:teiller2008

    /* 应用消息队列类 */
    struct AppQueue{
    struct AppFrame *pHead, *pTail;

    void (*InQueue)(struct AppQueue *papq, struct AppFrame *apf);
    struct AppFrame * (*OutQueue)(struct AppQueue *papq);
    unsigned char (*Empty)(struct AppQueue *papq);
    void (*ClearQueue)(struct AppQueue *papq);
    };

    /* AppQueue 类成员函数实体 */
    void apq_InQueue(struct AppQueue *papq, struct AppFrame *apf)
    {
    if(apf == NULL) return;

    apf->pNext = NULL;

    if(papq->pTail != NULL){
    papq->pTail->pNext = apf;
    papq->pTail = apf;
    }
    else{
    papq->pHead = papq->pTail = apf;
    }

    }

    struct AppFrame * apq_OutQueue(struct AppQueue *papq)
    {
    struct AppFrame *paf;

    paf = papq->pHead;

    if(papq->pHead != papq->pTail){
    papq->pHead = papq->pNext;
    }
    else{
    papq->pHead = papq->pTail = NULL;
    }

    return paf;
    }

    unsigned char apq_Empty(struct AppQueue *papq)
    {
    if((papq->pHead == papq->pTail) && (papq->pTail == NULL))
    return TRUE;
    else
    return FALSE;
    }

    void apq_ClearQueue(struct AppQueue *papq)
    {
    struct AppFrame *paf;
    while((paf = papq->OutQueue(papq)) != NULL){
    SysAppPool.Free(&SysAppPool, paf);
    }
    }

    /* AppQueue 类对象初始化 */
    void InitAppQueue(struct AppQueue *papq)
    {
    papq->pHead = papq->pTail = NULL;

    papq->InQueue = apq_InQueue;
    papq->OutQueue = apq_OutQueue;
    papq->Empty = apq_Empty;
    papq->ClearQueue = apq_ClearQueue;
    }

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载