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

📄 stringset.h

📁 C++&datastructure书籍源码,以前外教提供现在与大家共享
💻 H
字号:
#ifndef _STRINGSET_H
#define _STRINGSET_H

#include <string>
#include "tvector.h"
using namespace std;

class StringSet
{
  public:
    StringSet();
    StringSet(int isize);  // initialize size -- for efficiency

    // accessors
    bool contains(const string& s) const;
    int  size()                    const;

    // mutators
    void insert(const string& s);
    void erase (const string& s);
    void clear();

    friend class StringSetIterator;
  private:

    int    myCount;                // # of entries stored in myList
    tvector<string> myList;        // storage for each string
    
    int search(const string & key) const; // returns index in myList of key
};

class StringSetIterator
{
  public:
    StringSetIterator(const StringSet& s);

    void Init()      const;
    bool HasMore()   const;
    void Next()      const;
    string Current() const;
  private:
    const StringSet&  mySet;
    mutable int myIndex;
};

#endif

⌨️ 快捷键说明

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