?????????????????У??????????????????????????????????С???????????к?????????ī??????????????????????????????????????????????????????????????????????????——???????????????????С???????????????????????????????У?????????????С???????????????????????????????????洢???????????????????????????????????????????????????????????????????????????????????????????????????????????????У?????????????????β???????????????????????????????????????????????????β???в????????????????????????????в?????÷????????????????????β???????????????https://github.com/chenyufeng1991/Queue_LinkedList ??
??????????????£?
??????1???????????
????//????????????β???????????????
????void InitialQueue(Queue **pHead??Queue **pTail){
????*pHead = (Queue *)malloc(sizeof(Queue));
????*pTail = (Queue *)malloc(sizeof(Queue));
????if (*pHead == NULL || *pTail == NULL) {
????printf("%s??????У???????????????????????? "??__FUNCTION__);
????}else{
????//?????????????????п?????????
????(*pHead)->next = NULL;
????(*pTail)->prior = NULL;
????//?????????????????β?????????
????(*pHead)->prior = *pTail;
????(*pTail)->next = *pHead;
????printf("%s??????У????????β?????????????????????? "??__FUNCTION__);
????}
????}
??????2????????β?????????
????//??????????????β????????
????void EnQueue(Queue *head??Queue *tail??int x){
????Queue *pInsert;
????pInsert = (Queue *)malloc(sizeof(Queue));
????memset(pInsert?? 0?? sizeof(Queue));
????pInsert->next = NULL;
????pInsert->prior = NULL;
????pInsert->element = x;
????tail->next->prior = pInsert;
????pInsert->next = tail->next;
????tail->next = pInsert;
????pInsert->prior = tail;
????}
??????3???????????????????
????//???????????????????
????void DeQueue(Queue *head??Queue *tail){
????if (IsEmpty(head??tail)) {
????printf("????????????????? ");
????}else{
????Queue *pFreeNode;
????pFreeNode = head->prior;
????head->prior->prior->next = head;
????head->prior = head->prior->prior;
????free(pFreeNode);
????pFreeNode = NULL;
????}
????}
??????4????????н??
????//???????????????β???????????
????void PrintQueue(Queue *head??Queue *tail){
????Queue *pMove;
????pMove = head->prior;
????printf("????????е?????(????????):");
????while (pMove != tail) {
????printf("%d "??pMove->element);
????pMove = pMove->prior;
????}
????printf(" ");
????}
??????5???ж??????????
????//?ж?????????????????1????????0
????int IsEmpty(Queue *head??Queue *tail){
????if (head->prior == tail) {
????return 1;
????}
????return 0;
????}
??????6?????????
????int main(int argc?? const char * argv[]) {
????Queue *pHead;//????
????Queue *pTail;//β???
????InitialQueue(&pHead?? &pTail);
????EnQueue(pHead?? pTail?? 2);EnQueue(pHead?? pTail?? 1);
????EnQueue(pHead?? pTail?? 9);EnQueue(pHead?? pTail?? 3);EnQueue(pHead?? pTail?? 4);
????PrintQueue(pHead?? pTail);
????DeQueue(pHead??pTail);DeQueue(pHead??pTail);DeQueue(pHead??pTail);
????PrintQueue(pHead?? pTail);
????return 0;
????}