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

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

?? linkedlist.h

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

#include <iostream>
#include <cassert>

using namespace std;

//Definition of the node

template <class Type>
struct nodeType
{
	Type info;
	nodeType<Type> *link;
};

template <class Type>
class linkedListIterator
{
public:
   linkedListIterator();
     //Default constructor
     //Postcondition: current = NULL;

   linkedListIterator(nodeType<Type> *ptr);
     //Constructor with a parameter.
     //Postcondition: current = ptr;

   Type operator*();
     //Function to overload the dereferencing operator *.
     //Postcondition: Returns the info contained in the node.

   linkedListIterator<Type> operator++();    
     //Overload the pre-increment operator.
     //Postcondition: The iterator is advanced to the next 
     //               node.

   bool operator==(const linkedListIterator<Type>& right) const; 
     //Overload the equality operator.
     //Postcondition: Returns true if this iterator is equal to 
     //               the iterator specified by right, 
     //               otherwise it returns the value false.

   bool operator!=(const linkedListIterator<Type>& right) const; 
     //Overload the not equal to operator.
     //Postcondition: Returns true if this iterator is not  
     //               equal to the iterator specified by  
     //               right; otherwise it returns the value 
     //               false.

private:
   nodeType<Type> *current; //pointer to point to the current 
                            //node in the linked list
};

template <class Type>
linkedListIterator<Type>::linkedListIterator()
{
    current = NULL;
}

template <class Type>
linkedListIterator<Type>::
                  linkedListIterator(nodeType<Type> *ptr)
{
    current = ptr;
}

template <class Type>
Type linkedListIterator<Type>::operator*()
{
    return current->info;
}

template <class Type>
linkedListIterator<Type> linkedListIterator<Type>::operator++()   
{
    current = current->link;

    return *this;
}

template <class Type>
bool linkedListIterator<Type>::operator==
               (const linkedListIterator<Type>& right) const
{
    return (current == right.current);
}

template <class Type>
bool linkedListIterator<Type>::operator!=
                 (const linkedListIterator<Type>& right) const
{    return (current != right.current);
}


//*****************  class linkedListType   ****************

template <class Type>
class linkedListType
{
public:
    const linkedListType<Type>& operator=
                         (const linkedListType<Type>&);  
      //Overload the assignment operator.

    void initializeList(); 
      //Initialize the list to an empty state.
      //Postcondition: first = NULL, last = NULL, count = 0;

    bool isEmptyList() const;
      //Function to determine whether the list is empty. 
      //Postcondition: Returns true if the list is empty,
      //               otherwise it returns false.

    void print() const;
      //Function to output the data contained in each node.
      //Postcondition: none

    int length() const;
      //Function to return the number of nodes in the list.
      //Postcondition: The value of count is returned.

    void destroyList();
      //Function to delete all the nodes from the list.
      //Postcondition: first = NULL, last = NULL, count = 0;

    Type front() const; 
      //Function to return the first element of the list.
      //Precondition: The list must exist and must not be 
      //              empty.
      //Postcondition: If the list is empty, the program
      //               terminates; otherwise, the first 
      //               element of the list is returned.

    Type back() const; 
      //Function to return the last element of the list.
      //Precondition: The list must exist and must not be 
      //              empty.
      //Postcondition: If the list is empty, the program
      //               terminates; otherwise, the last  
      //               element of the list is returned.

    virtual bool search(const Type& searchItem) const = 0;
      //Function to determine whether searchItem is in the list.
      //Postcondition: Returns true if searchItem is in the 
      //               list, otherwise the value false is 
      //               returned.

    virtual void insertFirst(const Type& newItem) = 0;
      //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.

    virtual void insertLast(const Type& newItem) = 0;
      //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.

    virtual void deleteNode(const Type& deleteItem) = 0;
      //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.

    linkedListIterator<Type> begin();
      //Function to return an iterator at the begining of the 
      //linked list.
      //Postcondition: Returns an iterator such that current is
      //               set to first.

    linkedListIterator<Type> end();
      //Function to return an iterator one element past the 
      //last element of the linked list. 
      //Postcondition: Returns an iterator such that current is
      //               set to NULL.

    linkedListType(); 
      //default constructor
      //Initializes the list to an empty state.
      //Postcondition: first = NULL, last = NULL, count = 0; 

    linkedListType(const linkedListType<Type>& otherList); 
      //copy constructor

    ~linkedListType();   
      //destructor
      //Deletes all the nodes from the list.
      //Postcondition: The list object is destroyed. 

protected:
    int count;   //variable to store the number of 
                 //elements in the list
    nodeType<Type> *first; //pointer to the first node of the list
    nodeType<Type> *last;  //pointer to the last node of the list

private: 
    void copyList(const linkedListType<Type>& otherList); 
      //Function to make a copy of otherList.
      //Postcondition: A copy of otherList is created and
      //               assigned to this list.
};


template <class Type>
bool linkedListType<Type>::isEmptyList() const
{
    return(first == NULL);
}

template <class Type>
linkedListType<Type>::linkedListType() //default constructor
{
    first = NULL;
    last = NULL;
    count = 0;
}

template <class Type>
void linkedListType<Type>::destroyList()
{
    nodeType<Type> *temp;   //pointer to deallocate the memory
                            //occupied by the node
    while (first != NULL)   //while there are nodes in the list
    {
        temp = first;        //set temp to the current node
        first = first->link; //advance first to the next node
        delete temp;   //deallocate the memory occupied by temp
    }
    last = NULL; //initialize last to NULL; first has already
                 //been set to NULL by the while loop
    count = 0;
}

template <class Type>
void linkedListType<Type>::initializeList()
{
	destroyList(); //if the list has any nodes, delete them
}

template <class Type>
void linkedListType<Type>::print() const
{
    nodeType<Type> *current; //pointer to traverse the list

    current = first;    //set current so that it points to 
                        //the first node
    while (current != NULL) //while more data to print
    {
        cout << current->info << " ";
        current = current->link;
    }
}//end print

template <class Type>
int linkedListType<Type>::length() const
{
    return count;
}  //end length

template <class Type>
Type linkedListType<Type>::front() const
{   
    assert(first != NULL);

    return first->info; //return the info of the first node	
}//end front

template <class Type>
Type linkedListType<Type>::back() const
{   
    assert(last != NULL);

    return last->info; //return the info of the last node	
}//end back

template <class Type>
linkedListIterator<Type> linkedListType<Type>::begin()
{
    linkedListIterator<Type> temp(first);

    return temp;
}

template <class Type>
linkedListIterator<Type> linkedListType<Type>::end()
{
    linkedListIterator<Type> temp(NULL);

    return temp;
}

template <class Type>
void linkedListType<Type>::copyList
                   (const linkedListType<Type>& otherList) 
{
    nodeType<Type> *newNode; //pointer to create a node
    nodeType<Type> *current; //pointer to traverse the list

    if (first != NULL) //if the list is nonempty, make it empty
       destroyList();

    if (otherList.first == NULL) //otherList is empty
    {
        first = NULL;
        last = NULL;
        count = 0;
    }
    else
    {
        current = otherList.first; //current points to the 
                                   //list to be copied
        count = otherList.count;

            //copy the first node
        first = new nodeType<Type>;  //create the node

        first->info = current->info; //copy the info
        first->link = NULL;        //set the link field of 
                                   //the node to NULL
        last = first;              //make last point to the
                                   //first node
        current = current->link;     //make current point to
                                     //the next node

           //copy the remaining list
        while (current != NULL)
        {
            newNode = new nodeType<Type>;  //create a node
            newNode->info = current->info; //copy the info
            newNode->link = NULL;       //set the link of 
                                        //newNode to NULL
            last->link = newNode;  //attach newNode after last
            last = newNode;        //make last point to
                                   //the actual last node
            current = current->link;   //make current point 
                                       //to the next node
        }//end while
    }//end else
}//end copyList

template <class Type>
linkedListType<Type>::~linkedListType() //destructor
{
   destroyList();
}//end destructor

template <class Type>
linkedListType<Type>::linkedListType
                      (const linkedListType<Type>& otherList)
{
   	first = NULL;
    copyList(otherList);
}//end copy constructor

         //overload the assignment operator
template <class Type>
const linkedListType<Type>& linkedListType<Type>::operator=
                      (const linkedListType<Type>& otherList)
{ 
    if (this != &otherList) //avoid self-copy
    {
        copyList(otherList);
    }//end else

     return *this; 
}

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品无遮挡| 日韩欧美一卡二卡| 亚洲激情在线播放| 在线观看国产日韩| 日韩一区精品视频| 日韩一区二区三区视频| 国产福利91精品一区| 国产精品国产三级国产三级人妇 | 欧美国产日本韩| www.日韩av| 亚洲成人福利片| 久久日韩精品一区二区五区| 成人性生交大片免费看中文网站| 亚洲天堂免费在线观看视频| 欧美巨大另类极品videosbest| 日韩精品乱码av一区二区| 欧美大片一区二区| 国产mv日韩mv欧美| 亚洲一区二区3| 精品国产精品一区二区夜夜嗨| 岛国精品一区二区| 婷婷六月综合亚洲| 中文字幕二三区不卡| 欧美蜜桃一区二区三区| 国内一区二区在线| 一区二区三区不卡在线观看| 欧美精品一区二区不卡| 91黄视频在线| 福利电影一区二区三区| 天堂成人国产精品一区| 国产亲近乱来精品视频 | 91成人免费在线视频| 麻豆一区二区三区| 一区二区三区在线视频观看58| 欧美成人精精品一区二区频| 一本大道久久a久久精品综合| 秋霞电影网一区二区| 日韩一区日韩二区| 久久综合资源网| 欧美日韩午夜在线视频| 国产成人精品亚洲午夜麻豆| 日本不卡免费在线视频| 一区二区三区精品在线| 综合久久综合久久| 日韩欧美区一区二| 欧美日韩一区二区在线观看| 成人精品视频一区| 国产乱一区二区| 免费不卡在线观看| 亚洲国产精品麻豆| 中文字幕中文字幕中文字幕亚洲无线| 日韩一区二区电影在线| 色婷婷av一区二区三区大白胸| 国内一区二区视频| 日本视频免费一区| 亚洲一卡二卡三卡四卡五卡| 国产精品毛片大码女人| 久久香蕉国产线看观看99| 91精品欧美福利在线观看| 欧洲精品视频在线观看| 成人av午夜影院| 国产98色在线|日韩| 看电视剧不卡顿的网站| 亚洲国产日韩精品| 亚洲人成精品久久久久| 欧美国产亚洲另类动漫| 国产色爱av资源综合区| 久久久久国产精品免费免费搜索| 日韩午夜电影在线观看| 欧美精品久久天天躁| 欧美色爱综合网| 欧美日韩精品一区二区三区| 欧美午夜精品电影| 欧美日韩精品一区二区| 欧美亚洲一区二区三区四区| 色综合天天做天天爱| 99国产精品久| 91激情五月电影| 在线观看三级视频欧美| 欧美乱熟臀69xxxxxx| 91.com在线观看| 欧美一级在线观看| 精品日本一线二线三线不卡| 26uuu国产电影一区二区| 精品久久久久久久久久久院品网 | 国产精品久久久久一区二区三区| 精品国产1区2区3区| 精品国产乱码久久久久久影片| 欧美tickling挠脚心丨vk| 日韩欧美国产精品| 亚洲国产成人一区二区三区| 国产精品久久久久一区二区三区 | 精品久久久三级丝袜| 精品少妇一区二区三区视频免付费| 日韩欧美在线123| 久久女同互慰一区二区三区| 欧美激情一区二区| 亚洲一二三四区| 日本在线不卡视频一二三区| 国内精品第一页| 9l国产精品久久久久麻豆| 色综合久久中文综合久久97| 欧美三级电影一区| 日韩精品在线网站| 国产精品美女久久久久av爽李琼| 亚洲日本在线看| 午夜精品视频一区| 国产一区二区三区电影在线观看 | 在线观看一区二区精品视频| 9191久久久久久久久久久| ww久久中文字幕| 亚洲专区一二三| 国产精品影视网| 色域天天综合网| 欧美本精品男人aⅴ天堂| 亚洲人成精品久久久久| 日韩国产在线一| 成人av小说网| 日韩精品一区二区在线观看| 亚洲日本在线看| 国产最新精品精品你懂的| 色香蕉成人二区免费| 欧美一级黄色录像| 精品一区二区三区在线播放视频| 国产盗摄女厕一区二区三区| 欧美精品在线观看播放| 中文字幕在线视频一区| 美国十次综合导航| 在线观看免费视频综合| 久久久久久免费网| 日本成人超碰在线观看| 色呦呦国产精品| 久久久不卡影院| 免费一级片91| 欧洲国内综合视频| 18涩涩午夜精品.www| 久久精品国产秦先生| 欧美午夜电影一区| 中文字幕视频一区| 国产伦精品一区二区三区免费| 在线不卡一区二区| 亚洲国产精品久久久久婷婷884 | 欧美日韩一区小说| 中文字幕亚洲综合久久菠萝蜜| 九九**精品视频免费播放| 欧美少妇一区二区| 亚洲人成亚洲人成在线观看图片 | 亚洲高清不卡在线观看| 成人国产视频在线观看| 精品国产乱码久久久久久免费| 午夜精品一区二区三区免费视频 | 欧美高清视频不卡网| 亚洲黄色av一区| 91啪亚洲精品| 亚洲视频一区二区在线观看| 成人永久免费视频| 欧美国产日韩一二三区| 丰满亚洲少妇av| 国产午夜精品一区二区三区嫩草| 国产一区美女在线| 久久亚洲欧美国产精品乐播 | 亚洲777理论| 在线欧美日韩精品| 一区二区三国产精华液| 色哟哟一区二区| 亚洲狠狠丁香婷婷综合久久久| 91久久国产最好的精华液| 亚洲摸摸操操av| 在线观看不卡视频| 午夜精品福利视频网站| 欧美日本视频在线| 免费av成人在线| 久久夜色精品国产噜噜av| 国产91在线|亚洲| 国产精品毛片久久久久久| 97久久久精品综合88久久| 一区二区三区在线观看视频| 欧美系列在线观看| 免费在线观看一区二区三区| 久久综合久色欧美综合狠狠| 成人免费视频播放| 亚洲美女区一区| 欧美绝品在线观看成人午夜影视| 日韩在线a电影| 国产拍揄自揄精品视频麻豆| 99re8在线精品视频免费播放| 一区二区三区中文免费| 欧美日韩小视频| 国产另类ts人妖一区二区| 日韩一区欧美一区| 欧美电影一区二区| 国产精品一区二区果冻传媒| 亚洲欧美日韩国产一区二区三区| 在线观看网站黄不卡| 日韩中文欧美在线| 国产精品污网站| 欧美日韩视频专区在线播放| 国产一区二区主播在线| 亚洲欧洲精品一区二区精品久久久 | 国产不卡在线视频|