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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? linkedlist.h

?? C++編成數(shù)據(jù)結(jié)構(gòu)與程序設(shè)計方法 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麻豆精品在线观看| 福利视频网站一区二区三区| 国产在线日韩欧美| 激情深爱一区二区| 精品一区精品二区高清| 麻豆精品一二三| 久久91精品久久久久久秒播| 日韩中文字幕不卡| 奇米精品一区二区三区在线观看一 | 盗摄精品av一区二区三区| 国产高清在线精品| 成人一区二区三区中文字幕| 97se亚洲国产综合自在线不卡| 97精品久久久久中文字幕| 91久久精品一区二区二区| 欧美在线视频不卡| 欧美色爱综合网| 欧美一级片在线观看| 日韩精品自拍偷拍| 国产网站一区二区| 国产精品狼人久久影院观看方式| 亚洲麻豆国产自偷在线| 香蕉加勒比综合久久| 首页欧美精品中文字幕| 久久99热99| av一区二区三区| 欧美日韩中文字幕精品| 91精品免费在线观看| 国产午夜精品在线观看| 国产精品福利电影一区二区三区四区| 亚洲乱码国产乱码精品精的特点| 亚洲国产精品久久人人爱| 久久精品久久精品| 97成人超碰视| 日韩一级大片在线| 国产精品伦一区| 日韩精品一二三区| 国产成人啪午夜精品网站男同| 91最新地址在线播放| 91麻豆精品国产91久久久久久 | 成人性生交大片免费| 色狠狠桃花综合| 精品国产1区二区| 国产精品自产自拍| 日本大胆欧美人术艺术动态| 国产老女人精品毛片久久| 色综合色综合色综合色综合色综合| 6080国产精品一区二区| 国产欧美精品区一区二区三区| 亚洲一区二区三区四区在线观看 | 91精品国模一区二区三区| 欧美韩日一区二区三区四区| 天天综合日日夜夜精品| 国产91精品在线观看| 8x福利精品第一导航| 国产精品妹子av| 久久成人久久鬼色| 欧美午夜宅男影院| 欧美韩国日本综合| 毛片一区二区三区| 日本韩国一区二区三区视频| 久久精品男人天堂av| 亚洲国产视频网站| 成人美女视频在线观看18| 欧美一区二区三区在线观看| 亚洲欧美视频一区| 粉嫩aⅴ一区二区三区四区| 7777精品伊人久久久大香线蕉经典版下载 | 色8久久精品久久久久久蜜| 久久综合九色综合97_久久久| 午夜伦理一区二区| 99久久综合99久久综合网站| 欧美成人高清电影在线| 亚洲大片精品永久免费| 99国产欧美另类久久久精品 | 亚洲动漫第一页| 成人毛片在线观看| 国产亚洲一区字幕| 日本大胆欧美人术艺术动态| 欧美午夜电影一区| 国产精品久久久久四虎| 国产黄色精品视频| 精品捆绑美女sm三区| 日日夜夜免费精品| 欧美系列一区二区| 一区二区三区.www| 色综合久久中文字幕综合网| 国产精品美女一区二区| 国产伦理精品不卡| 久久久久国产精品厨房| 精品亚洲porn| 欧美成人女星排行榜| 青青草伊人久久| 91麻豆精品国产91久久久久| 婷婷久久综合九色国产成人 | 亚洲五月六月丁香激情| 在线精品视频一区二区三四| 一区二区三区在线观看欧美| 色狠狠av一区二区三区| 亚洲一区中文在线| 欧美写真视频网站| 午夜精品成人在线| 91精品婷婷国产综合久久| 日韩激情中文字幕| 日韩午夜av一区| 秋霞av亚洲一区二区三| 欧美成人a在线| 国产自产v一区二区三区c| 久久久综合九色合综国产精品| 经典一区二区三区| 2017欧美狠狠色| 国产91色综合久久免费分享| 亚洲欧洲av色图| 色悠悠久久综合| 亚洲国产视频直播| 日韩一区二区精品在线观看| 久久99深爱久久99精品| 国产日韩av一区| 91碰在线视频| 午夜精品福利一区二区蜜股av| 日韩欧美高清dvd碟片| 国产最新精品免费| 国产精品日产欧美久久久久| 91高清视频在线| 奇米精品一区二区三区在线观看一 | 欧美午夜精品一区二区蜜桃| 日韩国产欧美在线视频| 久久一区二区三区四区| 处破女av一区二区| 亚洲午夜久久久久久久久电影网 | 色欧美88888久久久久久影院| 亚洲福利视频一区二区| 日韩精品一区二区三区视频播放| 国产一区二区在线观看免费| 亚洲欧美日韩综合aⅴ视频| 欧美久久久影院| 国产黄色91视频| 亚洲一区视频在线| 精品成人佐山爱一区二区| 91在线丨porny丨国产| 日韩av电影一区| 国产精品久久久久久久久图文区| 欧美日韩亚州综合| 国产精品18久久久久久久久| 亚洲激情欧美激情| 亚洲精品一区二区三区蜜桃下载 | 国产成人午夜电影网| 亚洲香蕉伊在人在线观| 久久久久久久综合| 欧美丝袜丝nylons| 国产传媒日韩欧美成人| 亚洲成av人在线观看| 久久久久97国产精华液好用吗| 欧美在线三级电影| 国产精品一二二区| 首页亚洲欧美制服丝腿| 国产精品美女视频| 日韩欧美国产综合在线一区二区三区| 成人激情综合网站| 毛片不卡一区二区| 亚洲综合色成人| 久久久精品日韩欧美| 91麻豆精品国产综合久久久久久| 99re这里只有精品视频首页| 久久99国产精品成人| 亚洲国产精品欧美一二99| 国产精品卡一卡二卡三| 欧美精品一区男女天堂| 欧美日韩国产精品成人| gogogo免费视频观看亚洲一| 久久精品国产色蜜蜜麻豆| 午夜视频在线观看一区二区| 综合久久给合久久狠狠狠97色| 精品入口麻豆88视频| 欧美日韩另类一区| 99精品欧美一区| 成人激情开心网| 国产精品综合一区二区| 日韩电影在线一区二区三区| 一区二区三区四区视频精品免费 | 国产精品不卡一区二区三区| 精品国产91洋老外米糕| 欧美一二区视频| 精品视频在线免费观看| 91麻豆蜜桃一区二区三区| 成人午夜在线免费| 国产成人精品亚洲日本在线桃色| 麻豆精品一区二区综合av| 日韩国产高清影视| 五月天丁香久久| 亚洲成在线观看| 香蕉久久一区二区不卡无毒影院| 亚洲自拍偷拍欧美| 亚洲自拍与偷拍| 亚洲一区二区三区四区在线| 亚洲精选视频免费看| 亚洲另类一区二区|