亚洲欧美第一页_禁久久精品乱码_粉嫩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 conatined 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天天翘天天综合网| 国产自产v一区二区三区c| 91精品国产一区二区| 秋霞电影一区二区| 久久亚洲一区二区三区明星换脸| 久久99久久99精品免视看婷婷 | 亚洲视频每日更新| www.成人网.com| 亚洲成人免费观看| 亚洲精品一区二区三区在线观看| 国产一区二三区| 国产精品网曝门| 欧美三日本三级三级在线播放| 天天操天天色综合| 国产女主播一区| 99国产欧美久久久精品| 亚洲综合久久久久| 欧美第一区第二区| 成人h版在线观看| 亚洲国产视频一区| 91精品久久久久久久91蜜桃| 精品一区二区三区免费| 日韩毛片在线免费观看| 欧美在线免费视屏| 国产美女主播视频一区| 亚洲精品国产无天堂网2021| 欧美一区二区三区在线观看视频 | 亚洲成人av一区二区| 精品福利一区二区三区免费视频| 国产成人av电影在线| 亚洲一区二区黄色| 久久久久久影视| 91电影在线观看| 国产一区视频导航| 一区二区三区高清不卡| www久久精品| 欧美影院一区二区| 国产一区二区三区观看| 亚洲一区二区不卡免费| 久久久一区二区| 欧美男人的天堂一二区| 国产91丝袜在线播放0| 日日摸夜夜添夜夜添国产精品| 中文在线一区二区| 日韩一区二区三区四区| 91蜜桃网址入口| 国产成都精品91一区二区三| 婷婷成人综合网| 亚洲精品高清在线观看| 国产精品午夜免费| 精品三级在线看| 7777精品伊人久久久大香线蕉超级流畅 | 另类调教123区 | 中文字幕亚洲精品在线观看| 欧美变态凌虐bdsm| 欧美日韩一区精品| 91免费小视频| aa级大片欧美| 国产91丝袜在线播放| 极品少妇一区二区| 日韩成人免费在线| 日韩av成人高清| 视频一区欧美日韩| 亚洲成人动漫av| 亚洲午夜免费电影| 亚洲精品日韩一| 国产精品久久久久婷婷| 国产午夜久久久久| 久久久久久99久久久精品网站| 91精品欧美综合在线观看最新 | 日韩视频一区二区三区| 制服丝袜日韩国产| 在线播放日韩导航| 欧美人牲a欧美精品| 欧美精品在线观看一区二区| 欧美日韩日本视频| 欧美精品精品一区| 2020国产精品自拍| 精品国产91乱码一区二区三区| 91精品在线观看入口| 日韩女优av电影| www日韩大片| 日本一区二区免费在线观看视频| 日本一区二区三区高清不卡| 国产三区在线成人av| 欧美精彩视频一区二区三区| 国产精品久久久久婷婷二区次 | 一区二区不卡在线播放| 亚洲国产精品一区二区www| 视频一区二区中文字幕| 免费欧美在线视频| 国产麻豆视频一区二区| 国产精品一二三| 波多野结衣亚洲一区| 色综合中文综合网| 日本不卡一二三| 精品一区二区综合| 床上的激情91.| 91成人免费电影| 欧美精品三级在线观看| 精品久久久久久久久久久久久久久久久 | 欧美日韩精品电影| 欧美va亚洲va| 中文字幕一区视频| 亚洲综合丝袜美腿| 麻豆精品新av中文字幕| 成人国产精品免费观看| 欧美三区在线视频| 国产亚洲精品aa午夜观看| 亚洲日本一区二区三区| 奇米一区二区三区av| 国产剧情av麻豆香蕉精品| 一本大道av伊人久久综合| 欧美一区二区久久久| 国产日韩欧美激情| 亚洲激情自拍视频| 美腿丝袜亚洲一区| 99热99精品| 日韩美女一区二区三区四区| 一色桃子久久精品亚洲| 天天色综合天天| 菠萝蜜视频在线观看一区| 欧美猛男超大videosgay| 国产嫩草影院久久久久| 日产国产欧美视频一区精品| 成人永久免费视频| 日韩午夜av电影| 亚洲一级片在线观看| 国产伦理精品不卡| 精品视频色一区| 日韩一区中文字幕| 久久精品噜噜噜成人88aⅴ| 91丝袜美女网| 久久久久99精品国产片| 日韩精品一卡二卡三卡四卡无卡| 成人教育av在线| 欧美成人性福生活免费看| 一区二区三区四区高清精品免费观看 | 日本欧美在线观看| 99re这里只有精品6| 国产亚洲视频系列| 青青国产91久久久久久| 欧美偷拍一区二区| 国产精品三级电影| 激情综合五月婷婷| 7777精品伊人久久久大香线蕉超级流畅| 国产精品久久久久aaaa| 国产一区免费电影| 欧美一区二区三区小说| 亚洲一区二区三区四区五区黄| 成av人片一区二区| 国产日韩精品一区二区三区在线| 热久久久久久久| 在线不卡的av| 日韩国产欧美在线播放| 欧美三级电影网| 一区二区三区精品在线观看| 99久久精品一区二区| 国产精品区一区二区三区| 福利一区二区在线| 久久久久国产免费免费| 国产综合久久久久影院| 精品日本一线二线三线不卡| 蜜臂av日日欢夜夜爽一区| 欧美一区二区三区电影| 首页综合国产亚洲丝袜| 欧美日韩五月天| 图片区日韩欧美亚洲| 欧美日本精品一区二区三区| 视频一区视频二区中文| 欧美高清dvd| 麻豆成人在线观看| 精品国产免费一区二区三区四区| 免费成人性网站| 精品福利二区三区| 国内国产精品久久| 国产亚洲一区二区三区四区 | wwww国产精品欧美| 高清日韩电视剧大全免费| 国产精品区一区二区三区| 91在线观看下载| 亚洲已满18点击进入久久| 欧美日本一道本| 久久精品国产精品亚洲红杏| 久久久精品黄色| 91色porny在线视频| 亚洲午夜免费视频| 日韩欧美一级二级三级久久久| 国产精选一区二区三区| 中文字幕一区二区三区不卡| 91成人在线观看喷潮| 免费观看一级欧美片| 国产亚洲欧洲997久久综合| 成人av在线资源网站| 亚洲国产精品欧美一二99| 久久这里只有精品首页| 97aⅴ精品视频一二三区| 天天综合日日夜夜精品| 久久―日本道色综合久久|