⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ordlist.h

📁 经典数据结构书籍 数据结构C++语言描述 的源代码 很难找的哦
💻 H
字号:
#ifndef ORDERED_LIST_CLASSS
#define ORDERED_LIST_CLASSS

#include "seqlist2.h"

template <class T>
class OrderedList: public SeqList<T>
{
   public:
      // constructor
      OrderedList(void);
      
      // override Insert to form an ordered list.
      virtual void Insert(const T& item);
};

// constructor. initialize the base class
template <class T>
OrderedList<T>::OrderedList(void): SeqList<T>()
{}

// insert item into the list in ascending order
template <class T>
void OrderedList<T>::Insert(const T& item)
{
   // use the linked list traversal mechanism to locate the
   // insertion point
   for(llist.Reset();!llist.EndOfList();llist.Next())
      if (item < llist.Data())
         break;
         
   // insert item at the current list location
   llist.InsertAt(item);
   size++;
}

#endif   // ORDERED_LIST_CLASSS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -