inditer.h

来自「数据结构c++语言描述 Borland C++实现」· C头文件 代码 · 共 31 行

H
31
字号

// indirect list iterator

#ifndef IndirectListIterator_
#define IndirectListIterator_

template<class T>
class IndirectListIterator {
   public:
      T* Initialize(const IndirectList<T>& c)
             {if (c.length > 0) {// nonempty list
                                 length = c.length;
                                 table = c.table;
                                 location = 0;
                                 return table[0];
                                 }
              // empty list
              location = 0;
              return 0;}
      T* Next()
            {if (location >= length) return 0;
             location++;
             return table[location];}
   private:
      int location;  // current position in list
      int length;    // list length
      T **table;     // array of pointers
};
 
#endif

⌨️ 快捷键说明

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