亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
日本大胆欧美人术艺术动态 | 日本不卡免费在线视频| 成人在线视频一区| 亚洲国产成人av网| 欧美日本精品一区二区三区| 国内欧美视频一区二区| 欧美一区欧美二区| 欧美哺乳videos| 成人精品视频一区| 亚洲成av人片在线观看无码| 欧美一级日韩一级| 国产真实乱子伦精品视频| **欧美大码日韩| 欧美久久久久中文字幕| 亚洲一区二区三区在线播放 | 欧美一区二区三区四区在线观看| 国产1区2区3区精品美女| 中文字幕不卡在线观看| 成人免费视频视频在线观看免费| 国产日韩av一区二区| 91玉足脚交白嫩脚丫在线播放| 亚洲二区在线观看| 日韩欧美在线不卡| 国产麻豆视频精品| 欧美一区二区三区影视| 91免费观看在线| 国产在线看一区| 婷婷夜色潮精品综合在线| 2014亚洲片线观看视频免费| 精品国产露脸精彩对白| 成年人午夜久久久| 美国毛片一区二区三区| 色诱亚洲精品久久久久久| 午夜影院久久久| 久久99精品视频| 日韩av一区二| 欧美在线视频日韩| 久久99精品久久久久久动态图| 精品无码三级在线观看视频| 国产精品系列在线播放| 99综合影院在线| 欧美午夜片在线看| 日韩女优电影在线观看| 欧美丝袜自拍制服另类| 日韩精品一区二区三区中文不卡 | 国产精品国产三级国产三级人妇 | 蜜桃精品在线观看| 黄色小说综合网站| 91福利小视频| 欧美一级片在线观看| 欧美精品一区二区三区蜜臀| 国产精品乱人伦| 午夜亚洲福利老司机| 麻豆久久一区二区| 51精品久久久久久久蜜臀| 日韩视频一区二区三区在线播放| 国产农村妇女毛片精品久久麻豆| 亚洲一二三区视频在线观看| 午夜视频一区二区| 国产成人8x视频一区二区| 正在播放一区二区| 国产精品情趣视频| 樱桃视频在线观看一区| 国产一区二区三区黄视频 | 久久久青草青青国产亚洲免观| 中文字幕一区二区在线播放| 亚洲成av人片在线观看无码| 国产盗摄精品一区二区三区在线| 欧美在线你懂的| 精品国产乱码久久久久久老虎| 亚洲精品少妇30p| 国产在线精品一区二区| 欧美日韩一级片在线观看| 国产欧美日韩在线| 午夜欧美一区二区三区在线播放| 成人高清av在线| 欧美r级在线观看| 亚洲综合视频网| 高清不卡一区二区| 久久久久久99久久久精品网站| 亚洲午夜成aⅴ人片| 香蕉加勒比综合久久| 91日韩一区二区三区| 久久久久9999亚洲精品| 美国十次了思思久久精品导航| 色94色欧美sute亚洲13| 国产农村妇女精品| 国产精品77777| 欧美一区二区精品在线| 亚洲综合另类小说| 成人动漫一区二区在线| 久久久久久久久免费| 激情图区综合网| 91精品国产综合久久精品性色| 国产精品女主播av| 国产传媒久久文化传媒| 日韩一区二区三区免费看 | 色伊人久久综合中文字幕| wwwwww.欧美系列| 日本sm残虐另类| 成人午夜在线视频| 日韩精品一区在线观看| 视频一区免费在线观看| 在线免费观看视频一区| 中文字幕佐山爱一区二区免费| 亚洲超碰97人人做人人爱| 欧美日韩一区 二区 三区 久久精品| 中文字幕一区三区| 97精品国产97久久久久久久久久久久| 久久精品夜色噜噜亚洲aⅴ| 久久99精品国产麻豆不卡| 精品久久久久久最新网址| 麻豆极品一区二区三区| 日韩一级完整毛片| 日本成人在线视频网站| 51精品久久久久久久蜜臀| 美女高潮久久久| 日韩欧美国产一区二区在线播放| 久久精品人人做人人综合| 成人激情图片网| 中文字幕制服丝袜一区二区三区 | 肉色丝袜一区二区| 欧美日本在线观看| 亚洲欧美日韩中文播放| 色哟哟国产精品免费观看| 亚洲精品国产第一综合99久久| 色噜噜久久综合| 亚洲高清不卡在线| 9191久久久久久久久久久| 激情文学综合网| 国产日韩欧美制服另类| 一本色道**综合亚洲精品蜜桃冫| 夜夜爽夜夜爽精品视频| 欧美在线观看一区| 久久99精品国产.久久久久久| 久久久久久夜精品精品免费| 国产毛片精品国产一区二区三区| 欧美激情资源网| 色综合天天综合给合国产| 五月天中文字幕一区二区| 6080午夜不卡| 国产一区二区三区精品视频| 国产日产欧美一区二区三区| 91免费视频网| 视频精品一区二区| 久久久久久久久99精品| www.亚洲色图.com| 亚洲国产综合视频在线观看| 欧美精品第1页| 国产在线精品国自产拍免费| 国产精品高潮久久久久无| 精品视频在线免费观看| 蜜臀av一区二区三区| 中文字幕精品在线不卡| 色香蕉久久蜜桃| 激情综合色播五月| 国产精品视频yy9299一区| 91精品国产综合久久香蕉麻豆| 国精产品一区一区三区mba视频| 国产精品国产a级| 欧美一区日本一区韩国一区| 国产成人精品免费| 日韩不卡手机在线v区| 国产欧美在线观看一区| 欧美日韩视频在线第一区 | 91亚洲精品乱码久久久久久蜜桃| 亚洲免费三区一区二区| 欧美福利视频一区| 国产精品中文字幕一区二区三区| 亚洲一二三专区| 精品999久久久| 欧美精品777| 99精品欧美一区| 久久电影网站中文字幕| 亚洲超碰97人人做人人爱| 亚洲国产高清不卡| 久久亚洲综合色一区二区三区| 一本大道久久精品懂色aⅴ| 国产激情视频一区二区三区欧美| 亚洲午夜一二三区视频| 精品国产一区二区三区久久影院 | 精品欧美一区二区久久| 91社区在线播放| 日本aⅴ亚洲精品中文乱码| 亚洲激情图片qvod| 中文字幕免费一区| 久久精品亚洲乱码伦伦中文| 欧美三级午夜理伦三级中视频| 成人av电影免费在线播放| 六月婷婷色综合| 午夜精品久久久久久久| 亚洲精品久久嫩草网站秘色| 国产偷v国产偷v亚洲高清| 欧美精品一区二区在线播放| 在线不卡免费av| jlzzjlzz亚洲女人18| 国产乱人伦偷精品视频免下载| 日韩国产高清影视| 男女男精品视频| 日韩有码一区二区三区|