亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
久久99精品视频| 欧美色视频在线观看| 欧美v日韩v国产v| 精品在线免费视频| 久久久99久久| 91在线播放网址| 亚洲国产欧美在线| 欧美不卡视频一区| 成人午夜碰碰视频| 亚洲免费伊人电影| 911精品国产一区二区在线| 日韩综合在线视频| 久久精品免视看| 欧美中文字幕一二三区视频| 天天综合天天综合色| 日韩欧美不卡在线观看视频| 国产成人精品一区二区三区四区 | 亚洲最新视频在线播放| 色爱区综合激月婷婷| 国产婷婷精品av在线| 91啪亚洲精品| 美日韩一区二区三区| 国产日本一区二区| 欧美在线视频全部完| 激情成人综合网| 亚洲欧美韩国综合色| 99久久精品国产一区| 日韩综合在线视频| 国产精品久久久久天堂| 成人免费视频一区| 午夜免费久久看| 欧美精品 国产精品| 成人性色生活片免费看爆迷你毛片| 精品欧美一区二区在线观看| 天天影视涩香欲综合网 | 国产一区在线观看视频| 亚洲精品欧美综合四区| 精品盗摄一区二区三区| 欧美色偷偷大香| av在线不卡电影| 黑人精品欧美一区二区蜜桃| 亚洲成人在线观看视频| 国产精品久久久久婷婷 | 久久国产福利国产秒拍| 日韩女优制服丝袜电影| 91丨porny丨首页| 亚洲一区二区三区激情| 国产欧美一区视频| 日韩精品一区二区三区四区| 色婷婷综合久久久久中文一区二区 | 久久国产日韩欧美精品| 亚洲国产欧美一区二区三区丁香婷| 欧美日韩亚洲综合| 97se亚洲国产综合在线| 国产91富婆露脸刺激对白| 日产国产高清一区二区三区| 亚洲免费观看视频| 日韩毛片高清在线播放| 国产精品乱人伦| 国产亲近乱来精品视频| 久久久久久久久免费| 欧美sm极限捆绑bd| 日韩你懂的在线观看| 国产成人自拍高清视频在线免费播放| 国产精品美女久久久久久久久| 色悠久久久久综合欧美99| 99精品国产热久久91蜜凸| 亚洲国产三级在线| 一区二区日韩av| 亚洲视频一区在线| 中文字幕字幕中文在线中不卡视频| 欧美无砖砖区免费| 在线观看国产精品网站| 日本韩国精品在线| 91国内精品野花午夜精品| 免费观看日韩av| 久热成人在线视频| 免费人成在线不卡| 亚洲色图丝袜美腿| 一区二区三区四区在线| 久久久久久久久97黄色工厂| 久久久久久久久久久电影| 在线一区二区三区做爰视频网站| 蜜臀a∨国产成人精品| 麻豆91在线播放免费| 韩国精品久久久| 国产一区91精品张津瑜| 国产成人精品免费视频网站| 成人一区二区三区在线观看| a级高清视频欧美日韩| 欧洲亚洲国产日韩| 日韩一区二区三区在线观看| 精品人伦一区二区色婷婷| 中国色在线观看另类| 日韩一区二区三区av| 26uuu国产日韩综合| 国产精品欧美一区二区三区| 亚洲精品欧美综合四区| 免费在线看成人av| 国产a久久麻豆| 欧美日韩黄色一区二区| 日韩一区二区中文字幕| 欧美日韩久久一区| 精品国产一区二区三区不卡| 欧美电影一区二区| 久久久午夜精品理论片中文字幕| 日韩一二在线观看| 国产精品国产自产拍高清av王其| 久久无码av三级| 亚洲人成人一区二区在线观看| 国产免费观看久久| 亚洲成在线观看| 国产电影一区在线| 欧美日韩成人综合| 国产精品久久久久桃色tv| 日韩中文字幕一区二区三区| 国产69精品一区二区亚洲孕妇 | 91麻豆精品91久久久久久清纯| 99久久精品情趣| 日韩午夜av一区| 亚洲视频一二三| 免费高清成人在线| 91影视在线播放| 精品国产在天天线2019| 一区二区三区国产精华| 亚洲一区日韩精品中文字幕| 国产一区二区久久| 在线欧美日韩国产| 国产精品女上位| 麻豆久久久久久| 欧美日韩在线播放三区| 国产精品高潮呻吟久久| 国产一区二区三区免费播放| 欧美日韩一区在线观看| 中文字幕一区二区在线观看| 久久爱另类一区二区小说| 欧美日韩在线播| 亚洲欧美日本在线| 成人黄色软件下载| 欧美午夜一区二区三区| 中文字幕av一区二区三区高| 精品无人区卡一卡二卡三乱码免费卡| 毛片一区二区三区| 国产精品自拍毛片| 日韩一区二区三区观看| 一区二区在线观看免费视频播放| 亚洲国产中文字幕在线视频综合| 免费在线观看精品| 欧美日韩久久不卡| 亚洲激情欧美激情| 色综合天天综合色综合av| 国产精品福利电影一区二区三区四区| 亚洲黄色av一区| 99精品视频在线播放观看| 国产精品网站导航| 成人午夜视频网站| 中文字幕第一区综合| 风间由美一区二区av101 | 欧美写真视频网站| www国产成人| 亚洲三级在线免费| 99久精品国产| 亚洲视频一区二区在线| 亚洲超碰精品一区二区| 欧日韩精品视频| 伊人开心综合网| 欧美日韩国产首页| 日韩成人免费电影| 精品美女一区二区| 国产福利一区在线| 国产精品嫩草久久久久| 成熟亚洲日本毛茸茸凸凹| 色美美综合视频| 夜夜精品视频一区二区| 在线观看视频91| 久久久久久免费| 成人激情免费电影网址| 亚洲日本一区二区| 欧美日韩黄视频| 日本欧美大码aⅴ在线播放| 欧美精品一区二区在线播放| 高清不卡在线观看| 亚洲美女偷拍久久| 成人黄色小视频在线观看| 亚洲欧洲美洲综合色网| 国内成+人亚洲+欧美+综合在线| 欧美色图片你懂的| 久久99国产精品尤物| 欧美精彩视频一区二区三区| 一本在线高清不卡dvd| 日av在线不卡| 国产精品国产精品国产专区不蜜 | 国产69精品久久99不卡| 国产精品久久久久久久浪潮网站| 免播放器亚洲一区| 国产欧美精品一区| 国内精品视频666| 亚洲免费资源在线播放| 日韩一级二级三级| 欧美96一区二区免费视频|