stringset.h
来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C头文件 代码 · 共 47 行
H
47 行
#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 + =
减小字号Ctrl + -
显示快捷键?