双循环链表(包含头指针与尾指针)
以及基本功能的实现
list_ d_link_c.h
#ifndef _LIST_D_LINK_C_
#define _LIST_D_LINK_C_
#include<iostream>
#include<assert.h>
using namespace std;
#define ElemType int
typedef struct Node
{
ElemType data;
struct Node *prio;
struct Node *next;
}Node,*PNode;
typedef struct List
{
PNode first;
PNode last;
size_t size;
}List;
void Initlist(List *list);
void push_back(List *list,ElemType x);
void push_front(List *list,ElemType x);
bool pop_back(List *list);
bool pop_front(List *list);
void show_seqlist(List *list);
bool delete_val(List *list,ElemType key);
int length(List *list);
Node* find(List *list,ElemType key);
void clear(List *list);
void destroy(List *list);
bool next(List *list,ElemType key);
bool prio(List *list,ElemType key);
bool resver(List *list);
bool sort(List *list);//升序
bool modify(List *list,ElemType key);
bool insert_val(List *list,ElemType key);
#endif //_LIST_D_LINK_C_
list_ d_link_c.cpp
#include"Seqlist_ d_link_c.h"
void Initlist(List *list)
{
Node *s = (Node *)malloc(sizeof(Node));
assert(s != NULL);
list->first = list->last = s;
list->last->next = list->first;
list->first->prio = list->last;
list->size = 0;
}
void push_back(List *list,ElemType x)
{
Node *p = (Node *)malloc(sizeof(Node));
assert(p != NULL);
p->data = x;
p->next = list->first;
list->first->prio = p;
list->last->next = p;
p->prio = list->last;
list->last = p;
list->size++;
}
void push_front(List *list,ElemType x)
{
Node *p = (Node *)mall