/*
* @FileName: small_rtos_list.c
* @Author: chen jixuan
* @Date: 2021-04-29 20:39:42
* @Version: 当前版本
* @Description: 对该文件的描述
*/
#include "small_rtos_list.h"
/**
* @Name: InitList
* @Description: 初始化列表,未初始化的列表要求赋值为NULL,不然该函数无法初始化
* @Date: 2021-04-29 21:20:25
* @Author: chen jixuan
* @Return: 初始化成功返回true,失败返回false
* @param {POsList} *now_list
*/
bool InitList(POsList *now_list)
{
if (*now_list==NULL)
{
(*now_list) = (POsList)OsMalloc(sizeof(OsList));
if((*now_list)==NULL)
return FALSE;
(*now_list)->next_ = NULL;
(*now_list)->num_ = 0; //当前列表的节点数
(*now_list)->is_init_ = TRUE;
return TRUE;
}
else
{
return FALSE;
}
}
/**
* @Name: DestroyList
* @Description: 销毁列表
* @Date: 2021-04-29 21:21:37
* @Author: chen jixuan
* @Return: 成功返回true,失败返回false
* @param {POsList} *now_list
*/
bool DestroyList(POsList *now_list)
{
PListNode node;
PListNode temp;
if((*now_list)!=NULL&&(*now_list)->is_init_==TRUE)
{
node = (*now_list)->next_;
OsFree((*now_list));
(*now_list)=NULL;
while (node)
{
temp = node->next_;
OsFree(node);
node = temp;
}
return TRUE;
}
else
{
return FALSE;
}
}
/**
* @Name: ClaerList
* @Description: 清空列表
* @Date: 2021-04-29 21:23:30
* @Author: chen jixuan
* @Return: 成功返回true,失败返回false
* @param {POsList} now_list
*/
bool ClearList(POsList now_list)
{
PListNode ptr,qtr;
if(now_list!=NULL&&now_list->is_init_==TRUE)
{
ptr = now_list->next_;
while (ptr!=NULL)
{
qtr = ptr->next_;
OsFree(ptr);
ptr = qtr;
}
now_list->is_init_ = TRUE;
now_list->next_ = NULL;
now_list->num_ = 0;
return TRUE;
}
else
return FALSE;
}
/**
* @Name: ListAppend
* @Description: 向链表后面添加数据
* @Date: 2021-04-29 21:25:00
* @Author: chen jixuan
* @Return: 成功返回true,失败返回false
* @param {POsList} now_list
* @param {ListType} *dat
*/
bool ListAppend(POsList now_list,ListType *dat)
{
PListNode ptr;
if(now_list!=NULL&&now_list->is_init_)
{
ptr=now_list->next_;
if(now_list->next_==NULL)
{
now_list->next_=(PListNode)OsMalloc(sizeof(ListNode));
if(now_list->next_==NULL)
return FALSE;
now_list->next_->data_=*dat;
now_list->next_->next_=NULL;
now_list->num_=1;
return TRUE;
}
else
{
while(ptr->next_!=NULL)
{
ptr=ptr->next_;
}
ptr->next_=(PListNode)OsMalloc(sizeof(ListNode));
if(ptr->next_==NULL)
return FALSE;
ptr->next_->data_=*dat;
ptr->next_->next_=NULL;
now_list->num_+=1;
}
return TRUE;
}
return FALSE;
}
/**
* @Name: ListDelete
* @Description: 删除列表列的和给定元素相等的元素
* @Date: 2021-04-29 21:26:17
* @Author: chen jixuan
* @Return: 返回删除元素的后一个元素
* @param {POsList} now_list
*/
PListNode ListDelete(POsList now_list,ListType* now_data)
{
PListNode ptr;
PListNode qtr;
if(now_list!=NULL&&now_list->is_init_)
{
ptr=now_list->next_;
//对第一个节点单独处理
if(now_list->next_!=NULL)
{
if(CompareListType(&ptr->data_,now_data))
{
now_list->next_=ptr->next_;
OsFree(ptr);
now_list->num_-=1;
return now_list->next_;
}
}
else
return NULL;
while(ptr->next_!=NULL)
{
qtr=ptr;
ptr=ptr->next_;
if(CompareListType(&ptr->data_,now_data))
{
qtr->next_=ptr->next_;
OsFree(ptr);
now_list->num_-=1;
return qtr->next_;
}
}
}
return NULL;
}
/**
* @Name: IntCompare
* @Description: 用于对int形数据进行比较
* @Date: 2021-04-29 21:27:10
* @Author: chen jixuan
* @param {ListType} first_data
* @param {ListType} second_data
* @Return: 相等返回true,失败返回false
*/
bool CompareListType(ListType* first_data,ListType* second_data)
{
if(first_data->process_pid_==second_data->process_pid_)
return TRUE;
else
return FALSE;
}
/**
* @Name: ListFirstNode
* @Description:
* @Date: 2021-05-07 11:21:01
* @Author: chen jixuan
* @param {PosList} *now_list
* @Return: 链表第一个结点的指针
*/
PListNode ListFirstNode(POsList now_list)
{
if(now_list->num_==0)
return NULL;
else
return now_list->next_;
}
/**
* @Name: NodeFirstToLast
* @Description: 将链表最后一个数据移到最后一位
* @Date: 2021-05-07 11:26:34
* @Author: chen jixuan
* @Param:
* @Return:
* @param {PRadarList} now_list
*/
void NodeFirstToLast(POsList now_list)
{
PListNode temp_node;
PListNode p,q;
if(now_list->num_>=2)
{
temp_node=ListFirstNode(now_list);
now_list->next_=now_list->next_->next_;
p=now_list->next_;
q=p;
while(p!=NULL)
{
q=p;
p=p->next_;
}
temp_node->next_=NULL;
q->next_=temp_node;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51单片机上的简单操作系统.zip 一个跑在51单片机上的简单操作系统.zip一个跑在51
资源推荐
资源详情
资源评论
收起资源包目录
一个跑在51单片机上的简单操作系统.zip (40个子文件)
code_30312
small_rtos
os
os_register.h 10KB
small_rtos.asm 776B
os_rtos_malloc.h 701B
small_rtos_timer.h 210B
small_rtos_core.c 4KB
small_rtos_core.h 928B
small_rtos_main.c 399B
small_rtos_api.h 456B
small_rtos_hardware.h 583B
os_rtos_malloc.c 3KB
small_rtos_list.c 5KB
small_rtos_list.h 1KB
small_rtos_timer.c 321B
small_rtos_hardware.c 2KB
small_rtos_define.h 531B
.vscode
settings.json 203B
Objects
small_rtos.hex 23KB
small_rtos_timer.obj 8KB
small_rtos 56KB
small_rtos_hardware.obj 7KB
small_rtos_list.obj 20KB
small_rtos.obj 802B
small_rtos.build_log.htm 2KB
small_rtos_main.obj 3KB
small_rtos_core.obj 18KB
small_rtos.lnp 295B
os_rtos_malloc.obj 11KB
STARTUP.A51 6KB
small_rtos.uvproj 15KB
Listings
small_rtos_list.lst 10KB
small_rtos.lst 3KB
small_rtos_hardware.lst 4KB
small_rtos_core.lst 8KB
small_rtos.m51 39KB
my_list.lst 9KB
small_rtos_main.lst 2KB
small_rtos_timer.lst 1KB
os_rtos_malloc.lst 7KB
small_rtos.uvopt 9KB
small_rtos.uvgui.ccchenji 179KB
共 40 条
- 1
资源评论
龙年行大运
- 粉丝: 997
- 资源: 3856
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功