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

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

?? linkedlist.h

?? 上載的是c++源代碼
?? 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 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.

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

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

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

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


    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(last != 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 first node	
}//end back


template<class Type>
bool linkedListType<Type>::search(const Type& searchItem) const
{
    nodeType<Type> *current; //pointer to traverse the list
    bool found = false;
    
    current = first; //set current to point to the first 
                     //node in the list

    while (current != NULL && !found)    //search the list
        if (current->info == searchItem) //searchItem is found
            found = true;
        else
            current = current->link; //make current point to
                                     //the next node
    return found; 
}//end search

template<class Type>
void linkedListType<Type>::insertFirst(const Type& newItem)
{
   nodeType<Type> *newNode; //pointer to create the new node

   newNode = new nodeType<Type>; //create the new node

   assert(newNode != NULL);      //if unable to allocate memory, 
                                 //terminate the program

   newNode->info = newItem; 	   //store the new item in the node
   newNode->link = first;        //insert newNode before first
   first = newNode;              //make first point to the 
                                 //actual first node
   count++; 			   //increment count

   if (last == NULL)   //if the list was empty, newNode is also 
                      //the last node in the list
      last = newNode;
}//end insertFirst

template<class Type>
void linkedListType<Type>::insertLast(const Type& newItem)
{
   nodeType<Type> *newNode; //pointer to create the new node

   newNode = new nodeType<Type>; //create the new node

   assert(newNode != NULL);	//if unable to allocate memory, 
 					//terminate the program

   newNode->info = newItem;      //store the new item in the node
   newNode->link = NULL;         //set the link field of newNode
         				   //to NULL

   if (first == NULL)  //if the list is empty, newNode is 
     			    //both the first and last node
   {
	  first = newNode;
	  last = newNode;
	  count++;		//increment count
   }
   else     //the list is not empty, insert newNode after last
   {
	last->link = newNode; //insert newNode after last
	last = newNode;   //make last point to the actual last node
      count++;		//increment count
   }
}//end insertLast


template<class Type>
void linkedListType<Type>::deleteNode(const Type& deleteItem)
{
    nodeType<Type> *current; //pointer to traverse the list
    nodeType<Type> *trailCurrent; //pointer just before current
    bool found;

    if (first == NULL)    //Case 1; the list is empty. 
        cout << "Cannot delete from an empty list."
             << endl;
    else
    {
        if (first->info == deleteItem) //Case 2 
        {
            current = first;
            first = first->link;
            count--;
            if (first == NULL)    //the list has only one node
                last = NULL;
            delete current;
        }
        else //search the list for the node with the given info
        {
            found = false;
            trailCurrent = first;  //set trailCurrent to point
                                   //to the first node
            current = first->link; //set current to point to 
                                   //the second node

            while (current != NULL && !found)
            {
                if (current->info != deleteItem) 
                {
                    trailCurrent = current;
                    current = current-> link;
                }
                else
                    found = true;
            }//end while

            if (found) //Case 3; if found, delete the node
            {
                trailCurrent->link = current->link;
                count--;

                if (last == current)   //node to be deleted 
                                       //was the last node
                    last = trailCurrent; //update the value 
                                         //of last
                delete current;  //delete the node from the list
            }
            else
                cout << "The item to be deleted is not in "
                     << "the list." << endl;
        }//end else
    }//end else
}//end deleteNode

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

        assert(first != NULL);

        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

            assert(newNode != NULL);

            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久久精品久久久久久清纯| 国产精品美女久久久久久久久久久| 亚洲一区欧美一区| 972aa.com艺术欧美| 亚洲激情欧美激情| 精品视频在线看| 天堂久久一区二区三区| 日韩三级免费观看| 国产一区二区女| 中文字幕高清一区| 色美美综合视频| 视频一区国产视频| 久久只精品国产| 成人黄色a**站在线观看| 亚洲小少妇裸体bbw| 欧美大片免费久久精品三p| 国产超碰在线一区| 亚洲视频免费观看| 欧美一区二区在线不卡| 国产成人午夜精品影院观看视频| 国产精品美女一区二区| 欧美熟乱第一页| 精品一区二区三区在线观看国产 | 福利一区在线观看| 亚洲美女偷拍久久| 欧美草草影院在线视频| 福利电影一区二区| 视频一区视频二区中文字幕| 久久久久久久久久久久久女国产乱| 91美女蜜桃在线| 蜜乳av一区二区| 亚洲人xxxx| 亚洲精品一区二区三区蜜桃下载 | 亚洲欧美视频一区| 91精品国产入口在线| 国产91丝袜在线播放0| 亚洲福利视频导航| 国产精品入口麻豆九色| 欧美日韩免费在线视频| 国产精品中文欧美| 天天av天天翘天天综合网| 国产亚洲成av人在线观看导航| 91福利精品第一导航| 国产盗摄精品一区二区三区在线 | 亚洲福中文字幕伊人影院| 国产欧美一区二区精品忘忧草| 欧美日产在线观看| 波多野结衣中文一区| 国产综合久久久久久久久久久久| 一区二区久久久久久| 国产三级久久久| 日韩亚洲欧美综合| 欧美特级限制片免费在线观看| 国产黑丝在线一区二区三区| 蜜桃视频在线观看一区二区| 亚洲美女屁股眼交3| 国产欧美精品一区aⅴ影院| 日韩欧美一区二区免费| 欧美三区免费完整视频在线观看| 成人免费观看视频| 国产剧情一区二区| 久久99久久99| 日本一区中文字幕| 亚洲成国产人片在线观看| 亚洲激情综合网| 亚洲精品久久久久久国产精华液| 国产精品素人一区二区| 久久精品欧美一区二区三区不卡 | 色婷婷国产精品综合在线观看| 国产伦精品一区二区三区免费迷 | 亚洲欧美日韩一区二区 | 亚洲主播在线播放| 亚洲裸体在线观看| 亚洲欧美日韩综合aⅴ视频| 国产精品久久久久久久久快鸭| 久久久国产午夜精品 | 国产欧美日韩久久| 国产欧美日韩亚州综合 | 欧美性xxxxxx少妇| 欧美午夜精品免费| 欧美视频你懂的| 欧美日韩一区三区四区| 欧美日韩一区二区三区在线| 欧美午夜片在线看| 91精品国产综合久久蜜臀| 制服丝袜在线91| 欧美不卡视频一区| 久久久久久亚洲综合| 国产精品久久久久9999吃药| 一区在线观看视频| 一区二区中文视频| 一级日本不卡的影视| 三级精品在线观看| 麻豆精品国产传媒mv男同 | 97se亚洲国产综合在线| 一本到三区不卡视频| 在线观看网站黄不卡| 欧美日韩综合一区| 日韩亚洲欧美在线| 日本一区二区三区高清不卡| 综合在线观看色| 视频精品一区二区| 久久99精品久久只有精品| 国产一区久久久| 91麻豆免费观看| 欧美色综合网站| 欧美mv日韩mv| 日韩毛片精品高清免费| 一区二区三区资源| 日韩av网站免费在线| 国产乱码精品一区二区三区av| 成人一级黄色片| 91国产成人在线| 日韩一级片网站| 国产精品乱码久久久久久| 亚洲一区在线观看网站| 韩国v欧美v亚洲v日本v| 成人黄色电影在线 | 国产精品中文欧美| 91久久一区二区| 亚洲精品在线电影| 亚洲色图都市小说| 麻豆免费看一区二区三区| 成人午夜私人影院| 4438x成人网最大色成网站| 国产欧美中文在线| 日本最新不卡在线| www.性欧美| 欧美成人一区二区三区在线观看| 亚洲欧美在线视频观看| 日本不卡一区二区| av一区二区三区黑人| 日韩精品一区二区三区视频| 玉米视频成人免费看| 国产乱子伦视频一区二区三区 | 亚洲情趣在线观看| 国产在线精品国自产拍免费| 欧美三区免费完整视频在线观看| 国产农村妇女毛片精品久久麻豆| 亚洲丰满少妇videoshd| 91社区在线播放| 久久久久久久性| 久久99久久99| 91麻豆精品国产| 一区二区三区欧美在线观看| 国产馆精品极品| 26uuu亚洲婷婷狠狠天堂| 午夜精品视频一区| 欧美午夜一区二区三区| 亚洲欧美另类图片小说| www.日韩在线| 亚洲国产精品国自产拍av| 国产一区二区三区电影在线观看| 在线播放中文字幕一区| 亚洲精品免费播放| 色哟哟亚洲精品| 亚洲欧美日韩电影| 91丨porny丨户外露出| 国产欧美日本一区视频| 国产成人精品影视| 26uuu亚洲综合色欧美| 国产在线不卡一卡二卡三卡四卡| 91精品欧美一区二区三区综合在 | 成人精品视频一区| 欧美—级在线免费片| 久草中文综合在线| 日韩三级中文字幕| 美女视频一区二区三区| 欧美日韩一区二区三区高清 | 日本三级亚洲精品| 欧美三级日本三级少妇99| 亚洲欧美另类小说| 色88888久久久久久影院野外 | 国产精品素人视频| 99在线精品视频| 亚洲欧美偷拍三级| 在线一区二区视频| 亚洲影视资源网| 91.成人天堂一区| 日本成人在线视频网站| 日韩一区二区免费电影| 蜜桃传媒麻豆第一区在线观看| 欧美高清视频在线高清观看mv色露露十八 | 亚洲精品成a人| 欧美美女激情18p| 蜜臀久久久99精品久久久久久| 日韩精品一区二区三区在线| 奇米影视7777精品一区二区| 日韩精品专区在线影院观看 | 美女脱光内衣内裤视频久久网站| 欧美videofree性高清杂交| 精品亚洲porn| 久久精品人人做人人爽人人| 成人夜色视频网站在线观看| 亚洲色图在线视频| 欧美精品电影在线播放| 国产尤物一区二区在线| 国产亲近乱来精品视频| 在线中文字幕不卡| 美脚の诱脚舐め脚责91|