亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? unorderedlinkedlist.h

?? C++編成數據結構與程序設計方法 D.S.Malk編著
?? H
字號:
#ifndef H_UnorderedLinkedList
#define H_UnorderedLinkedList

#include "linkedList.h"

using namespace std;

template <class Type>
class unorderedLinkedList: public linkedListType<Type>
{
public:
    bool search(const Type& searchItem) const;
      //Function to determine whether searchItem is in the list.
      //Postcondition: Returns true if searchItem is in the 
      //               list, otherwise the value false is 
      //               returned.

    void insertFirst(const Type& newItem);
      //Function to insert newItem at the beginning of the list.
      //Postcondition: first points to the new list, newItem is
      //               inserted at the beginning of the list,
      //               last points to the last node in the  
      //               list, and count is incremented by 1.

    void insertLast(const Type& newItem);
      //Function to insert newItem at the end of the list.
      //Postcondition: first points to the new list, newItem 
      //               is inserted at the end of the list,
      //               last points to the last node in the 
      //               list, and count is incremented by 1.

    void deleteNode(const Type& deleteItem);
      //Function to delete deleteItem from the list.
      //Postcondition: If found, the node containing 
      //               deleteItem is deleted from the list.
      //               first points to the first node, last
      //               points to the last node of the updated 
      //               list, and count is decremented by 1.

    void mergeSort();

private:
    void recMergeSort(nodeType<Type>* &head);
    void divideList(nodeType<Type>* first1, 
                    nodeType<Type>* &first2);
    nodeType<Type>* mergeList(nodeType<Type>* first1, 
                              nodeType<Type>* first2);

};


template<class Type>
bool unorderedLinkedList<Type>::
                   search(const Type& searchItem) const
{
    nodeType<Type> *current; //pointer to traverse the list
    bool found = false;
    
    current = first; //set current to point to the first 
                     //node in the list

    while (current != NULL && !found)    //search the list
        if (current->info == searchItem) //searchItem is found
            found = true;
        else
            current = current->link; //make current point to
                                     //the next node
    return found; 
}//end search

template<class Type>
void unorderedLinkedList<Type>::insertFirst(const Type& newItem)
{
   nodeType<Type> *newNode; //pointer to create the new node

   newNode = new nodeType<Type>; //create the new node

   assert(newNode != NULL);      //if unable to allocate memory, 
                                 //terminate the program

   newNode->info = newItem; 	   //store the new item in the node
   newNode->link = first;        //insert newNode before first
   first = newNode;              //make first point to the 
                                 //actual first node
   count++; 			   //increment count

   if (last == NULL)   //if the list was empty, newNode is also 
                      //the last node in the list
      last = newNode;
}//end insertFirst

template<class Type>
void unorderedLinkedList<Type>::insertLast(const Type& newItem)
{
    nodeType<Type> *newNode; //pointer to create the new node

    newNode = new nodeType<Type>; //create the new node

    assert(newNode != NULL);    //if unable to allocate memory,
                                //terminate the program

    newNode->info = newItem;   //store the new item in the node
    newNode->link = NULL;   //set the link field of newNode
                            //to NULL

    if (first == NULL)  //if the list is empty, newNode is 
                        //both the first and last node
    {
        first = newNode;
        last = newNode;
        count++;        //increment count
    }
    else    //the list is not empty, insert newNode after last
    {
        last->link = newNode; //insert newNode after last
        last = newNode; //make last point to the actual 
                        //last node in the list
        count++;        //increment count
    }
}//end insertLast


template<class Type>
void unorderedLinkedList<Type>::deleteNode(const Type& deleteItem)
{
    nodeType<Type> *current; //pointer to traverse the list
    nodeType<Type> *trailCurrent; //pointer just before current
    bool found;

    if (first == NULL)    //Case 1; the list is empty. 
        cout << "Cannot delete from an empty list."
             << endl;
    else
    {
        if (first->info == deleteItem) //Case 2 
        {
            current = first;
            first = first->link;
            count--;
            if (first == NULL)    //the list has only one node
                last = NULL;
            delete current;
        }
        else //search the list for the node with the given info
        {
            found = false;
            trailCurrent = first;  //set trailCurrent to point
                                   //to the first node
            current = first->link; //set current to point to 
                                   //the second node

            while (current != NULL && !found)
            {
                if (current->info != deleteItem) 
                {
                    trailCurrent = current;
                    current = current-> link;
                }
                else
                    found = true;
            }//end while

            if (found) //Case 3; if found, delete the node
            {
                trailCurrent->link = current->link;
                count--;

                if (last == current)   //node to be deleted 
                                       //was the last node
                    last = trailCurrent; //update the value 
                                         //of last
                delete current;  //delete the node from the list
            }
            else
                cout << "The item to be deleted is not in "
                     << "the list." << endl;
        }//end else
    }//end else
}//end deleteNode

template <class Type>
void unorderedLinkedList<Type>::
               divideList(nodeType<Type>* first1, 
                          nodeType<Type>* &first2)
{
    nodeType<Type>* middle;
    nodeType<Type>* current;

    if (first1 == NULL)   //list is empty
        first2 = NULL;
    else if (first1->link == NULL)  //list has only one node
        first2 = NULL;
    else
    {
        middle = first1;
        current = first1->link;

        if (current != NULL)    //list has more than two nodes
            current = current->link;
        while (current != NULL)
        {
            middle = middle->link;
            current = current->link;
            if (current != NULL)
                current = current->link;
        } //end while

        first2 = middle->link; //first2 points to the first 
                               //node of the second sublist
        middle->link = NULL;   //set the link of the last node
                               //of the first sublist to NULL
    } //end else
} //end divideList

template<class Type>
nodeType<Type>* unorderedLinkedList<Type>::
                  mergeList(nodeType<Type>* first1, 
                            nodeType<Type>* first2)
{
    nodeType<Type> *lastSmall; //pointer to the last node of 
                               //the merged list
    nodeType<Type> *newHead;   //pointer to the merged list

    if (first1 == NULL)   //the first sublist is empty
        return first2;
    else if (first2 == NULL)   //the second sublist is empty
        return first1;
    else
    {
        if (first1->info < first2->info) //compare the 
                                         //first nodes
        {
            newHead = first1;  
            first1 = first1->link;
            lastSmall = newHead;
        }
        else
        {
            newHead = first2;
            first2 = first2->link;
            lastSmall = newHead;
        }
 
        while (first1 != NULL && first2 != NULL)
        {
            if (first1->info < first2->info)
            {
                lastSmall->link = first1;
                lastSmall = lastSmall->link;
                first1 = first1->link;
            }
            else
            {
                lastSmall->link = first2;
                lastSmall = lastSmall->link;
                first2 = first2->link;
            }
        } //end while

        if (first1 == NULL) //first sublist is exhausted first
            lastSmall->link = first2;
        else               //second sublist is exhausted first
            lastSmall->link = first1;

        return newHead;
    } 
}//end mergeList

template<class Type>
void unorderedLinkedList<Type>::recMergeSort(
                                    nodeType<Type>* &head)
{
    nodeType<Type> *otherHead;

    if (head != NULL)  //if the list is not empty
        if (head->link != NULL)  //if the list has more than 
                                 //one node
        {
            divideList(head, otherHead);
            recMergeSort(head);
            recMergeSort(otherHead);
            head = mergeList(head, otherHead);
        }
} //end recMergeSort

template<class Type>
void unorderedLinkedList<Type>::mergeSort()
{
    recMergeSort(first);

    if (first == NULL)
        last = NULL;
    else
    {
        last = first;
        while (last->link != NULL)
            last = last->link;
    }
} //end mergeSort

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美电影免费观看高清完整版| 欧美三级欧美一级| 色网站国产精品| 欧美日本精品一区二区三区| 日本精品免费观看高清观看| 精品久久久网站| 一区二区视频在线看| 国产精品一区久久久久| 国产福利一区二区三区视频| 亚洲一区免费视频| 成人性生交大片| 欧美tickling挠脚心丨vk| 亚洲一区二区三区四区不卡| 蜜臀av性久久久久av蜜臀妖精| 色综合久久久网| 欧美国产日韩一二三区| 水野朝阳av一区二区三区| 国产电影一区在线| 日韩一卡二卡三卡四卡| 国产亚洲一本大道中文在线| 青青草成人在线观看| 精品视频在线视频| 国产农村妇女毛片精品久久麻豆 | 欧美日韩视频不卡| 国产精品久久久久久亚洲毛片| 久久成人麻豆午夜电影| 99精品国产一区二区三区不卡| 日韩欧美国产一区二区三区| 亚洲综合丁香婷婷六月香| 色哟哟一区二区| 欧美va日韩va| 国产自产v一区二区三区c| 欧美大度的电影原声| 男人的天堂亚洲一区| 337p亚洲精品色噜噜狠狠| 久久精品视频一区| 免费av网站大全久久| 欧美自拍丝袜亚洲| 一区二区三区在线观看国产| 国产成人午夜电影网| 91精品一区二区三区久久久久久| 亚洲欧洲日本在线| 91色.com| 一区二区三区在线视频观看58| 91福利资源站| 亚洲成在人线免费| 欧美日韩高清一区二区| 国产精品视频一二| 不卡免费追剧大全电视剧网站| 国产欧美精品区一区二区三区| 国产福利一区二区| 精品国产乱码久久久久久牛牛| 丝袜美腿亚洲一区| 日韩色视频在线观看| 美女视频一区在线观看| 日韩无一区二区| 成人性生交大片免费看中文网站| 欧美日韩一区二区三区不卡| 成人免费在线视频| 97se亚洲国产综合自在线不卡| 亚洲欧美偷拍另类a∨色屁股| 韩国三级中文字幕hd久久精品| 国产欧美日韩另类视频免费观看| 成人福利视频在线看| 自拍偷自拍亚洲精品播放| 欧美性高清videossexo| 亚洲综合成人在线| 不卡的av网站| 亚洲成人tv网| www精品美女久久久tv| 懂色av一区二区三区免费观看| 久久午夜免费电影| 本田岬高潮一区二区三区| 亚洲国产精品久久久久婷婷884| 欧美午夜理伦三级在线观看| 日日骚欧美日韩| 国产午夜精品一区二区| 国内久久婷婷综合| 一区二区三区欧美视频| 日韩午夜精品视频| 色一情一乱一乱一91av| 亚洲日本在线观看| 精品久久人人做人人爽| 欧美综合欧美视频| 久久国产综合精品| 欧美成人一区二区| 99精品视频免费在线观看| 日韩欧美视频在线| 不卡区在线中文字幕| 日韩精品福利网| 国产精品美女一区二区在线观看| 狠狠久久亚洲欧美| 日本怡春院一区二区| 中文字幕一区二区三区不卡| 日韩色在线观看| 欧美日韩一区二区三区在线看| 风间由美一区二区av101| 亚洲激情在线激情| 一本一本大道香蕉久在线精品| 国内外成人在线视频| 男女男精品网站| 午夜影院久久久| 日韩免费观看高清完整版 | 亚洲精品国产品国语在线app| 337p日本欧洲亚洲大胆精品| 欧美精品亚洲二区| 欧美精选一区二区| 日本大香伊一区二区三区| 精品一区二区三区在线观看 | 国产清纯白嫩初高生在线观看91 | 日韩久久精品一区| 欧美精品三级在线观看| 国产成人亚洲精品青草天美| 激情小说欧美图片| 国产一区999| 国产精品一级片在线观看| 日韩中文字幕亚洲一区二区va在线| 一区二区三区在线观看欧美| 亚洲欧美另类久久久精品| 国产精品久久久久久久岛一牛影视| 国产亚洲一区二区三区在线观看| 国产欧美日韩视频一区二区| 亚洲国产精品v| 国产午夜久久久久| 国产亚洲美州欧州综合国| 国产日产欧美一区二区视频| 久久久久久免费网| 国产亚洲精品中文字幕| 欧美一区在线视频| 精品成a人在线观看| 国产色产综合色产在线视频| 国产精品免费丝袜| 一区二区三区国产精品| 婷婷国产在线综合| 久久国产精品免费| 卡一卡二国产精品| 国产高清视频一区| 一本到三区不卡视频| 欧美三级视频在线播放| 日韩精品一区二区三区在线播放| 精品国产一区二区在线观看| 国产精品久久久久久一区二区三区| 一区二区三区 在线观看视频| 天堂一区二区在线免费观看| 蜜臀91精品一区二区三区 | 欧美久久高跟鞋激| 久久亚洲精品国产精品紫薇| 亚洲色欲色欲www在线观看| 一区二区欧美视频| 蜜臀99久久精品久久久久久软件| 高清国产一区二区| 在线欧美日韩精品| 久久在线观看免费| 一区二区高清视频在线观看| 久久精品国产亚洲高清剧情介绍| 白白色亚洲国产精品| 欧美日韩高清一区二区三区| 久久久美女毛片| 亚洲一区二区三区美女| 国产精品18久久久久久久久久久久| 91在线观看视频| 精品国产一区二区精华| 亚洲免费伊人电影| 韩国v欧美v亚洲v日本v| 欧美在线色视频| 国产欧美一区二区三区沐欲 | 欧美高清视频不卡网| 国产精品欧美经典| 日本在线不卡一区| 972aa.com艺术欧美| 久久久久久久综合| 午夜久久久久久电影| 成人性生交大片免费看在线播放 | 日本韩国一区二区三区| 中文字幕欧美日本乱码一线二线| 亚洲 欧美综合在线网络| 97久久超碰国产精品| 久久久影院官网| 老司机精品视频一区二区三区| 色激情天天射综合网| 日本一区二区成人| 国产盗摄视频一区二区三区| 欧美一卡二卡三卡| 亚洲国产裸拍裸体视频在线观看乱了| 成人avav影音| 久久久久久久久久久久久夜| 美女视频一区在线观看| 欧美精品电影在线播放| 亚洲一级不卡视频| 色噜噜狠狠成人网p站| 国产精品激情偷乱一区二区∴| 加勒比av一区二区| 日韩欧美在线网站| 欧美a级理论片| 欧美一区二区精品久久911| 亚洲一区在线播放| 91成人国产精品| 国产精品视频一二三区| www.66久久| 一区二区三区在线视频播放|