数据结构(顺序表-头文件)

来源:互联网 发布:装修木工注意事项知乎 编辑:程序博客网 时间:2024/05/08 23:27
#ifndef _LIST_FILE#define LIST_INIT_SIZE 100#define LISTINCREMENT 10typedef int ElemType;typedef struct  {ElemType *elem;  /* 基地址 */int length;      /* 链表长度 */int listSize;    /* 链表容量 */}SqList;/* 构造一个空的线性表 */int InitList(SqList &L);/* 销毁线性表 */void DestoryList(SqList &L);/* 将L重置为空表 */int ClearList(SqList &L);/* 若L为空表,返回为false,否者返回true */bool ListEmpty(SqList L);/* 获取线性表中元素的个数 */int ListLength(SqList L);/* 用e返回L中第i个元素的值 */int GetElem(SqList L, int i, ElemType &e);/* 判定函数 */bool compare(ElemType a, ElemType b);/* 返回第一个与e满足关系compare()的数据元素的位序,若这样的数据元素不存在,则返回值为0 */int LocateElem(SqList L, ElemType e,  void *fun(ElemType, ElemType));/* 若cur_e是L的数据元素,且不是第一个,则用pre_e返回它的前驱,否则操作失败,pre_e无定义 */int PriorElem(SqList L, ElemType cur_e, ElemType &pre_e);/* 若cur_e是L的数据元素, 且不是最后一个,则next_e返回它的后继,否则操作失败,next_e无定义 */int NextElem(SqList L, ElemType cur_e, ElemType &next_e);/* 在L中第i个位置之前插入新的数据元素e,L的长度加1 */int ListInsert(SqList &L, int i, ElemType e);/* 删除L的第i个数据元素,并且用e返回其值,L的长度减1 */int ListDelete(SqList &L, int i, ElemType &e);#endif
0 0
原创粉丝点击