kx-000006-判空,判满()-其他
kx-000006-判空,判满()
- 顺序表结构体定义。具体的结构体定义请查看头文件:https://www.cnblogs.com/kxwslmsps/p/16937235.html
typedef status int; // 定义函数结果状态
typedef int etype; // 元素数据类型
#define CAPACITY 10 // 定义初始容量/**
* @brief 可变长顺序表的表结构: \n
* @param[in] etype* pbase:表基址
* @param[in] int capacity:表容量
* @param[in] int size:表当前长度
*/
typedef struct tag_seqList
{
etype* pbase;
int capacity;
int size;
}mySList;
typedef status int; // 定义函数结果状态
typedef int etype; // 元素数据类型
#define CAPACITY 10 // 定义初始容量
/**
* @brief 可变长顺序表的表结构: \n
* @param[in] etype* pbase:表基址
* @param[in] int capacity:表容量
* @param[in] int size:表当前长度
*/
typedef struct tag_seqList
{
etype* pbase;
int capacity;
int size;
}mySList;
- 判空和判满
/**
* @brief 功能: 判空\n
* @param[in] plist:表结构指针
* @return 返回表是否为空的结果状态标志
* @retval – ERROR(-1):表结构不存在,不可操作
* @retval – TRUE(1):表为空
* @retval – FALSE(0):表非空
*/
status sList_epmty(const mySList* plist)
{
if (plist == NULL || plist->pbase == NULL)
{
return ERROR;
}
return (plist->size == 0) ? TRUE : FALSE;
}/**
* @brief 功能: 判满\n
* @param[in] plist:表结构指针
* @return 返回表是否为满的结果状态标志
* @retval – ERROR(-1):表结构不存在,不可操作
* @retval – TRUE(1):表为满
* @retval – FALSE(0):表非满
*/
status sList_full(const mySList* plist)
{
if (plist == NULL || plist->pbase == NULL)
{
return ERROR;
}
return (plist->size == plist->capacity) ? TRUE : FALSE;
}
/**
* @brief 功能: 判空\n
* @param[in] plist:表结构指针
* @return 返回表是否为空的结果状态标志
* @retval - ERROR(-1):表结构不存在,不可操作
* @retval - TRUE(1):表为空
* @retval - FALSE(0):表非空
*/
status sList_epmty(const mySList* plist)
{
if (plist == NULL || plist->pbase == NULL)
{
return ERROR;
}
return (plist->size == 0) ? TRUE : FALSE;
}
/**
* @brief 功能: 判满\n
* @param[in] plist:表结构指针
* @return 返回表是否为满的结果状态标志
* @retval - ERROR(-1):表结构不存在,不可操作
* @retval - TRUE(1):表为满
* @retval - FALSE(0):表非满
*/
status sList_full(const mySList* plist)
{
if (plist == NULL || plist->pbase == NULL)
{
return ERROR;
}
return (plist->size == plist->capacity) ? TRUE : FALSE;
}
- 顺序表结构体定义。具体的结构体定义请查看头文件:https://www.cnblogs.com/kxwslmsps/p/16937235.html
typedef status int; // 定义函数结果状态
typedef int etype; // 元素数据类型
#define CAPACITY 10 // 定义初始容量/**
* @brief 可变长顺序表的表结构: \n
* @param[in] etype* pbase:表基址
* @param[in] int capacity:表容量
* @param[in] int size:表当前长度
*/
typedef struct tag_seqList
{
etype* pbase;
int capacity;
int size;
}mySList;
typedef status int; // 定义函数结果状态
typedef int etype; // 元素数据类型
#define CAPACITY 10 // 定义初始容量
/**
* @brief 可变长顺序表的表结构: \n
* @param[in] etype* pbase:表基址
* @param[in] int capacity:表容量
* @param[in] int size:表当前长度
*/
typedef struct tag_seqList
{
etype* pbase;
int capacity;
int size;
}mySList;
- 判空和判满
/**
* @brief 功能: 判空\n
* @param[in] plist:表结构指针
* @return 返回表是否为空的结果状态标志
* @retval – ERROR(-1):表结构不存在,不可操作
* @retval – TRUE(1):表为空
* @retval – FALSE(0):表非空
*/
status sList_epmty(const mySList* plist)
{
if (plist == NULL || plist->pbase == NULL)
{
return ERROR;
}
return (plist->size == 0) ? TRUE : FALSE;
}/**
* @brief 功能: 判满\n
* @param[in] plist:表结构指针
* @return 返回表是否为满的结果状态标志
* @retval – ERROR(-1):表结构不存在,不可操作
* @retval – TRUE(1):表为满
* @retval – FALSE(0):表非满
*/
status sList_full(const mySList* plist)
{
if (plist == NULL || plist->pbase == NULL)
{
return ERROR;
}
return (plist->size == plist->capacity) ? TRUE : FALSE;
}
/**
* @brief 功能: 判空\n
* @param[in] plist:表结构指针
* @return 返回表是否为空的结果状态标志
* @retval - ERROR(-1):表结构不存在,不可操作
* @retval - TRUE(1):表为空
* @retval - FALSE(0):表非空
*/
status sList_epmty(const mySList* plist)
{
if (plist == NULL || plist->pbase == NULL)
{
return ERROR;
}
return (plist->size == 0) ? TRUE : FALSE;
}
/**
* @brief 功能: 判满\n
* @param[in] plist:表结构指针
* @return 返回表是否为满的结果状态标志
* @retval - ERROR(-1):表结构不存在,不可操作
* @retval - TRUE(1):表为满
* @retval - FALSE(0):表非满
*/
status sList_full(const mySList* plist)
{
if (plist == NULL || plist->pbase == NULL)
{
return ERROR;
}
return (plist->size == plist->capacity) ? TRUE : FALSE;
}