Libevent分解之数据结构Circlequeue
来源:互联网 发布:3dmax专业优化 编辑:程序博客网 时间:2024/05/16 23:35
#define _TEST_STRUCT_C
//结构体定义
struct Student
{
//业务数据
const char name[32];
int id;
int classID;
//下面的字段纯粹是为了建立链表用
struct TstField
{
struct Student *sle_next;
} MyField;
LIST_ENTRY(Student) ListField;
SIMPLEQ_ENTRY(Student) SQueueField;
TAILQ_ENTRY(Student) TQueueField;
CIRCLEQ_ENTRY(Student) CQueueField;
};
void* NewStudent();
#endif
#ifndef _TEST_CIRCLE_C
#define _TEST_CIRCLE_C
#include "innerStruct.h"
CIRCLEQ_HEAD(StudentCircleQueue,Student);
struct StudentCircleQueue sutCircleHead;
void TestCircleQueue();
static void OutputAll();
static void OutputAllR();
#endif
#include <stdio.h>
#include <stdlib.h>
#include "queue.h"
#include "innerStruct.h"
#include "CircleQueue.h"
void TestCircleQueue()
{
struct Student *stu;
struct Student *stu1;
struct Student *stu2;
char tem[32];
int i;
CIRCLEQ_INIT(&sutCircleHead);
//进入队列
for(i=0;i<10;i++)
{
stu=NewStudent();
if(NULL==stu){return;}
stu->classID=i;
stu->id=100;
sprintf(tem,"jiayp%d",i+1);
strcpy(stu->name,tem);
CIRCLEQ_INSERT_TAIL(&sutCircleHead,stu,CQueueField);
}
OutputAll();
OutputAllR();
}
static void OutputAllR()
{
struct Student *stu3;
CIRCLEQ_FOREACH_REVERSE(stu3,&sutCircleHead,CQueueField)
{
printf(stu3->name);
printf("\r\n");
}
printf("\r\n");
}
static void OutputAll()
{
struct Student *stu3;
CIRCLEQ_FOREACH(stu3,&sutCircleHead,CQueueField)
{
printf(stu3->name);
printf("\r\n");
}
printf("\r\n");
}
- Libevent分解之数据结构Circlequeue
- Libevent分解之数据结构List
- Libevent分解之数据结构SimpleQueue
- Libevent分解之数据结构Tailqueue
- Libevent分解之数据结构 哈希表
- libevent分解之数据结构 小根堆
- Libevent 分解之数据结构 Singly-linked List
- Libevent分解之数据结构- 字典表
- 数据结构之分解质因数
- libevent源码详解(一)数据结构之尾队列
- libevent源码详解(二)数据结构之最小堆
- libevent源码详解(三)数据结构之event、event_base
- libevent主要数据结构
- libevent中的基本数据结构
- Libevent数据结构分析
- 【转载】libevent核心数据结构
- libevent数据结构-TAILQ_QUEUE队列
- libevent数据结构尾队列
- 隐藏或显示iphone的状态条
- 基于ASP.NET的自定义分页显示
- ASP.NET创建Web服务之异步Web服务(二)
- Ubuntu网络配置以DHCP方式配置网卡
- c# Invoke和BeginInvoke 区别
- Libevent分解之数据结构Circlequeue
- ASP.NET创建Web服务之异步Web服务(一)
- NIO系列6:流行 NIO Framework netty 和 mina 性能测评与分析
- ASP.NET创建Web服务之异步Web
- 一些资料
- 用ASP.NET结合XML制作广告管理程序(二)
- poj 未解动态规划题目
- 排序算法总结(六)归并排序
- poj_1082_Calendar Game(博弈论)