📄 dictionary.h
字号:
#ifndef DICTIONARY_H
#define DICTIONARY_H
#include "LinkedList.h"
template<class K,class V>
class Dictionary
{
public:
bool put(K key,V value)
{
if (keys.find(key)==-1)
{
keys.add(key);
values.add(value);
return true;
}
return false;
}
V get(K key)
{
int index=keys.find(key);
if (index==-1)
{
return NULL;
}
return values.get(index);
}
void clear()
{
keys.clear();
values.clear();
}
int size()
{
return keys.size();
}
LinkedList<K> getKeys()
{
return keys;
}
bool remove(K key)
{
int index=keys.find(key);
if (index==-1)
{
return false;
}
keys.remove(index);
values.remove(index);
return true;
}
protected:
LinkedList<K> keys;
LinkedList<V> values;
private:
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -