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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? chainwithbinsort.h

?? datastucutre and algorithms, application, in C
?? H
字號(hào):
// chain with bin sort included

#ifndef chain_
#define chain_

#include<iostream>
#include<sstream>
#include<string>
#include "linearList.h"
#include "chainNode.h"
#include "myExceptions.h"
#include "studentRecord2.h"

using namespace std;

template<class T>
class chain : public linearList<T> 
{
   public:
      // constructor, copy constructor and destructor
      chain(int initialCapacity = 10);
      chain(const chain<T>&);
      ~chain();

      // ADT methods
      bool empty() const {return listSize == 0;}
      int size() const {return listSize;}
      T& get(int theIndex) const;
      int indexOf(const T& theElement) const;
      void erase(int theIndex);
      void insert(int theIndex, const T& theElement);
      void output(ostream& out) const;

      // additional methods
      void binSort(int range);
      void binSort(int range, int(*value)(T& x));

   protected:
      void checkIndex(int theIndex) const;
            // throw illegalIndex if theIndex invalid
      chainNode<T>* firstNode;  // pointer to first node in chain
      int listSize;             // number of elements in list
};

template<class T>
chain<T>::chain(int initialCapacity)
{// Constructor.
   if (initialCapacity < 1)
   {ostringstream s;
    s << "Initial capacity = " << initialCapacity << " Must be > 0";
    throw illegalParameterValue(s.str());
   }
   firstNode = NULL;
   listSize = 0;
}

template<class T>
chain<T>::chain(const chain<T>& theList)
{// Copy constructor.
   listSize = theList.listSize;

   if (listSize == 0)
   {// theList is empty
      firstNode = NULL;
      return;
   }

   // non-empty list
   chainNode<T>* sourceNode = theList.firstNode;
                    // node in theList to copy from
   firstNode = new chainNode<T>(sourceNode->element);
                    // copy first element of theList
   sourceNode = sourceNode->next;
   chainNode<T>* targetNode = firstNode;
                    // current last node in *this
   while (sourceNode != NULL)
   {// copy remaining elements
      targetNode->next = new chainNode<T>(sourceNode->element);
      targetNode = targetNode->next;
      sourceNode = sourceNode->next;
   }
   targetNode->next = NULL; // end the chain
}

template<class T>
chain<T>::~chain()
{// Chain destructor. Delete all nodes in chain.
   chainNode<T> *nextNode;
   while (firstNode != NULL)
   {// delete firstNode
      nextNode = firstNode->next;
      delete firstNode;
      firstNode = nextNode;
   }
}

template<class T>
void chain<T>::checkIndex(int theIndex) const
{// Verify that theIndex is between 0 and listSize - 1.
   if (theIndex < 0 || theIndex >= listSize)
   {ostringstream s;
    s << "index = " << theIndex << " size = " << listSize;
    throw illegalIndex(s.str());
   }

}

template<class T>
T& chain<T>::get(int theIndex) const
{// Return element whose index is theIndex.
 // Throw illegalIndex exception if no such element.
   checkIndex(theIndex);

   // move to desired node
   chainNode<T>* currentNode = firstNode;
   for (int i = 0; i < theIndex; i++)
      currentNode = currentNode->next;

   return currentNode->element;
}

template<class T>
int chain<T>::indexOf(const T& theElement) const
{// Return index of first occurrence of theElement.
 // Return -1 if theElement not in list.

   // search the chain for theElement
   chainNode<T>* currentNode = firstNode;
   int index = 0;  // index of currentNode
   while (currentNode != NULL && 
          currentNode->element != theElement)
   {
      // move to next node
      currentNode = currentNode->next;
      index++;
   }

   // make sure we found matching element
   if (currentNode == NULL)
      return -1;
   else
      return index;
}

template<class T>
void chain<T>::erase(int theIndex)
{// Delete the element whose index is theIndex.
 // Throw illegalIndex exception if no such element.
   checkIndex(theIndex);

   // valid index, locate node with element to delete
   chainNode<T>* deleteNode;
   if (theIndex == 0)
   {// remove first node from chain
      deleteNode = firstNode;
      firstNode = firstNode->next;
   }
   else 
   {  // use p to get to predecessor of desired node
      chainNode<T>* p = firstNode;
      for (int i = 0; i < theIndex - 1; i++)
         p = p->next;
   
      deleteNode = p->next;
      p->next = p->next->next; // remove deleteNode from chain
   }
   listSize--;
   delete deleteNode;
}

template<class T>
void chain<T>::insert(int theIndex, const T& theElement)
{// Insert theElement so that its index is theIndex.
   if (theIndex < 0 || theIndex > listSize)
   {// invalid index
      ostringstream s;
      s << "index = " << theIndex << " size = " << listSize;
      throw illegalIndex(s.str());
   }

   if (theIndex == 0)
      // insert at front
      firstNode = new chainNode<T>(theElement, firstNode);
   else
   {  // find predecessor of new element
      chainNode<T>* p = firstNode;
      for (int i = 0; i < theIndex - 1; i++)
         p = p->next;
   
      // insert after p
      p->next = new chainNode<T>(theElement, p->next);
   }
   listSize++;
}

template<class T>
void chain<T>::output(ostream& out) const
{// Put the list into the stream out.
   for (chainNode<T>* currentNode = firstNode;
                      currentNode != NULL;
                      currentNode = currentNode->next)
      out << currentNode->element << "  ";
}

// overload <<
template <class T>
ostream& operator<<(ostream& out, const chain<T>& x)
   {x.output(out); return out;}


template<class T>
void chain<T>::binSort(int range)
{// Sort the nodes in the chain.
   // create and initialize the bins
   chainNode<T> **bottom, **top;
   bottom = new chainNode<T>* [range + 1];
   top = new chainNode<T>* [range + 1];
   for (int b = 0; b <= range; b++)
      bottom[b] = NULL;
   
   // distribute to bins
   for (; firstNode != NULL; firstNode = firstNode->next)
   {// add firstNode to proper bin
      int theBin = firstNode->element; // type conversion to int
      if (bottom[theBin] == NULL) // bin is empty
        bottom[theBin] = top[theBin] = firstNode;
      else
      {// bin not empty
        top[theBin]->next = firstNode;
        top[theBin] = firstNode;
      }
   }
   
   // collect from bins into sorted chain
   chainNode<T> *y = NULL;
   for (int theBin = 0; theBin <= range; theBin++)
      if (bottom[theBin] != NULL)
      {// bin not empty
         if (y == NULL) // first nonempty bin
            firstNode = bottom[theBin];
         else // not first nonempty bin
            y->next = bottom[theBin];
         y = top[theBin];
      }  
   if (y != NULL)
      y->next = NULL;
   
   delete [] bottom;
   delete [] top;
}

template<class T>
void chain<T>::binSort(int range, int(*value)(T& x))
{// Sort the nodes in the chain. The sort key is value(theElement).
   // create and initialize the bins
   chainNode<T> **bottom, **top;
   bottom = new chainNode<T>* [range + 1];
   top = new chainNode<T>* [range + 1];
   for (int b = 0; b <= range; b++)
      bottom[b] = NULL;
   
   // distribute to bins
   for (; firstNode != NULL; firstNode = firstNode->next)
   {// add firstNode to proper bin
      int theBin = value(firstNode->element);
                         // type conversion to int
      if (bottom[theBin] == NULL) // bin is empty
        bottom[theBin] = top[theBin] = firstNode;
      else
      {// bin not empty
        top[theBin]->next = firstNode;
        top[theBin] = firstNode;
      }
   }
   
   // collect from bins into sorted chain
   chainNode<T> *y = NULL;
   for (int theBin = 0; theBin <= range; theBin++)
      if (bottom[theBin] != NULL)
      {// bin not empty
         if (y == NULL) // first nonempty bin
            firstNode = bottom[theBin];
         else // not first nonempty bin
            y->next = bottom[theBin];
         y = top[theBin];
      }  
   if (y != NULL)
      y->next = NULL;
   
   delete [] bottom;
   delete [] top;
}
#endif

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线亚洲欧美专区二区| 欧美裸体bbwbbwbbw| 一区二区三区欧美| 日韩精品中文字幕在线不卡尤物| 国产成人午夜片在线观看高清观看| 亚洲六月丁香色婷婷综合久久| 欧美一二三区精品| 色综合夜色一区| 国产精品亚洲综合一区在线观看| 亚洲影视在线播放| 亚洲国产精品成人综合| 欧美一区二区三区喷汁尤物| av电影一区二区| 国产在线精品一区二区三区不卡| 午夜免费欧美电影| 亚洲女同ⅹxx女同tv| 久久精品亚洲麻豆av一区二区 | 成人精品视频一区二区三区| 视频一区欧美精品| 亚洲男人的天堂av| 中文字幕亚洲区| 国产日韩精品视频一区| 欧美成人精精品一区二区频| 欧美视频在线播放| 色综合激情久久| 不卡视频一二三| 高潮精品一区videoshd| 精品一区二区成人精品| 日韩电影在线免费| 香蕉久久一区二区不卡无毒影院| 亚洲日本一区二区| 国产精品久久久久9999吃药| 久久精子c满五个校花| 日韩三级高清在线| 欧美一区二区三区免费视频| 欧美福利一区二区| 欧美日韩高清不卡| 欧美区一区二区三区| 欧美日韩中文一区| 欧美日韩精品一区视频| 欧美日韩国产首页| 欧美精选一区二区| 91精品中文字幕一区二区三区| 欧美日韩一区小说| 欧美日韩国产天堂| 日韩欧美一区在线| 精品国产1区二区| 久久久不卡网国产精品二区| 26uuuu精品一区二区| 久久久综合精品| 国产亚洲欧美一区在线观看| 国产欧美日韩不卡| 中文字幕中文在线不卡住| 中文字幕一区二区视频| 亚洲欧洲美洲综合色网| 亚洲精品美腿丝袜| 亚洲mv在线观看| 九九国产精品视频| 国产成人免费在线观看| 97精品国产97久久久久久久久久久久 | 久久精品99国产国产精| 另类小说综合欧美亚洲| 国产美女主播视频一区| 不卡一区二区中文字幕| 欧美亚洲禁片免费| 日韩欧美亚洲国产精品字幕久久久| 欧美成人精品3d动漫h| 日本一区二区成人在线| 成人免费在线视频| 亚洲va欧美va人人爽| 黑人巨大精品欧美黑白配亚洲| 国产成人一区在线| 欧美性猛交一区二区三区精品| 欧美一级片免费看| 国产日韩亚洲欧美综合| 一区二区三区久久| 蜜臀av性久久久久蜜臀aⅴ| 国产99精品国产| 欧洲在线/亚洲| www久久久久| 一级特黄大欧美久久久| 老汉av免费一区二区三区| 国产**成人网毛片九色| 欧美日韩亚洲综合一区| 国产亚洲成av人在线观看导航| 亚洲精品亚洲人成人网| 蜜桃视频在线一区| 99国产精品国产精品久久| 欧美一级理论性理论a| 国产精品国产成人国产三级| 丝袜亚洲另类丝袜在线| 成人午夜激情视频| 91精品国产色综合久久| 国产精品狼人久久影院观看方式| 日韩精品一二区| 91网站最新地址| 日韩视频一区二区| 亚洲一区二区三区激情| 成人黄页毛片网站| 精品日韩成人av| 亚洲国产日日夜夜| 成人丝袜高跟foot| 精品美女被调教视频大全网站| 亚洲人123区| 国产成人在线色| 日韩一区二区三区av| 一级精品视频在线观看宜春院| 国产99久久久精品| 欧美精品一区二区三区在线播放| 亚洲成人午夜影院| 97se亚洲国产综合自在线| 久久影院电视剧免费观看| 日日夜夜免费精品| 欧美综合一区二区三区| 国产精品美女久久久久久| 国产一区二区三区免费播放| 91精品国产综合久久小美女| 亚洲综合一区二区精品导航| 成人av在线影院| 国产清纯在线一区二区www| 麻豆一区二区99久久久久| 欧美在线视频日韩| 亚洲精品国产精品乱码不99| 丁香一区二区三区| 国产午夜精品一区二区| 国产一区二区网址| 日韩精品一区二区三区四区视频| 午夜精品久久久久久久久| 91久久久免费一区二区| 一区二区三区在线观看动漫| 91影视在线播放| 18成人在线视频| 91在线视频免费观看| 亚洲美女视频在线观看| 色域天天综合网| 一区二区三区在线视频观看| 在线视频国产一区| 亚洲综合免费观看高清完整版在线| 色88888久久久久久影院按摩| 亚洲精品写真福利| 欧美三级蜜桃2在线观看| 五月天丁香久久| 91麻豆精品国产91| 精品一区二区三区免费| 久久精品亚洲国产奇米99| 高清不卡在线观看av| |精品福利一区二区三区| 一本色道久久加勒比精品| 亚洲午夜精品在线| 91精品国产91综合久久蜜臀| 蜜桃av一区二区三区电影| 久久综合久久鬼色中文字| 成人毛片在线观看| 有坂深雪av一区二区精品| 欧美无砖专区一中文字| 日韩av在线播放中文字幕| 精品久久久久99| 99综合影院在线| 亚洲香蕉伊在人在线观| 欧美一区二区人人喊爽| 国产美女娇喘av呻吟久久| **性色生活片久久毛片| 色婷婷精品久久二区二区蜜臀av | 日韩一区二区三区av| 国产在线播放一区二区三区| 国产精品久久久久影院| 日本韩国欧美三级| 麻豆国产欧美日韩综合精品二区| 国产亚洲精久久久久久| 欧洲精品一区二区三区在线观看| 日韩综合一区二区| 久久在线观看免费| 在线免费观看日本欧美| 久久成人免费网| 成人欧美一区二区三区1314| 精品视频一区 二区 三区| 极品瑜伽女神91| 亚洲免费色视频| 日韩欧美一卡二卡| 99久久er热在这里只有精品15| 亚洲超碰97人人做人人爱| 久久亚洲精精品中文字幕早川悠里| 91色综合久久久久婷婷| 美脚の诱脚舐め脚责91| 亚洲免费在线播放| 亚洲精品一区二区精华| 欧美在线免费播放| 国产91精品在线观看| 亚洲国产精品久久久久婷婷884 | 久久久久久久久久久久久久久99| 色综合久久综合中文综合网| 久久国产日韩欧美精品| 亚洲精品视频一区二区| 久久久久久久久久久黄色| 欧美三级日韩在线| 成人免费视频播放| 久久精品二区亚洲w码| 亚洲图片欧美一区| 亚洲国产成人自拍| 日韩欧美电影一二三|