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

📄 nodelist.h

📁 一个组合模式的例子
💻 H
字号:
#ifndef _NODELIST_H_
#define _NODELIST_H_

#include <iostream>

#define DEFAULT_LIST_CAPACITY 50

typedef struct _NodeInfo
{
  char name[32];
  char ip[16];
  int channel;
}NodeInfo;

template <class Item>
class List
{
  public:
    List (long size = DEFAULT_LIST_CAPACITY);
    ~List(void);
  
    long Count () const;
    Item Get(long index) const;
    long Add(Item item);
    void Remove(Item item);
  private:
    Item *Items;
    long count;
};

template <class Item>
class Iterator
{
  public:
    //Iterator(const List<Item> *alist);
    virtual void First() = 0;
    virtual void Next() = 0;
    virtual bool IsDone() const = 0;
    virtual Item CurrentItem() const = 0;

};

template <class Item>
class ListIterator : public Iterator<Item>
{
  public:
    ListIterator(const List<Item> *alist);
    virtual void First();
    virtual void Next();
    virtual bool IsDone() const;
    virtual Item CurrentItem() const;
  private:
    const List<Item> *_list;
    long _current;
};

#endif

⌨️ 快捷键说明

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