SimpleWindow
载入中...
搜索中...
未找到
sw::Dictionary< TKey, TVal > 模板类 参考

字典类,内部维护了一个指向std::map的智能指针 更多...

#include <Dictionary.h>

Public 成员函数

 Dictionary ()
 初始化字典
 
 Dictionary (std::initializer_list< std::pair< const TKey, TVal > > list)
 使用初始化列表
 
auto begin () const
 正向迭代器开始
 
auto end () const
 正向迭代器结束
 
auto rbegin () const
 反向迭代器开始
 
auto rend () const
 反向迭代器结束
 
auto & operator[] (const TKey &key) const
 获取或设置值
 
bool operator== (const Dictionary &other) const
 判断是否为同一个字典
 
bool operator!= (const Dictionary &other) const
 判断是否不是同一个字典
 
int Count () const
 获取键值对个数
 
bool IsEmpty () const
 字典是否为空
 
auto Add (const TKey &key, const TVal &value) const
 添加键值对到字典
 
bool ContainsKey (const TKey &key) const
 是否存在某个键值
 
bool ContainsValue (const TVal &value) const
 遍历字典,查询是否存在某个值
 
void Remove (const TKey &key) const
 移除指定键值对
 
void Clear () const
 清空字典
 
Dictionary Copy () const
 复制当前字典
 

友元

std::wostream & operator<< (std::wostream &wos, const Dictionary &dic)
 支持Utils::BuildStr
 

详细描述

template<typename TKey, typename TVal>
class sw::Dictionary< TKey, TVal >

字典类,内部维护了一个指向std::map的智能指针

成员函数说明

◆ Add()

template<typename TKey , typename TVal >
auto sw::Dictionary< TKey, TVal >::Add ( const TKey & key,
const TVal & value ) const
inline

添加键值对到字典

返回
当前字典

◆ ContainsKey()

template<typename TKey , typename TVal >
bool sw::Dictionary< TKey, TVal >::ContainsKey ( const TKey & key) const
inline

是否存在某个键值

参数
key要查询的键值

◆ ContainsValue()

template<typename TKey , typename TVal >
bool sw::Dictionary< TKey, TVal >::ContainsValue ( const TVal & value) const
inline

遍历字典,查询是否存在某个值

参数
value要查询的值

◆ operator[]()

template<typename TKey , typename TVal >
auto & sw::Dictionary< TKey, TVal >::operator[] ( const TKey & key) const
inline

获取或设置值

参数
key键值

◆ Remove()

template<typename TKey , typename TVal >
void sw::Dictionary< TKey, TVal >::Remove ( const TKey & key) const
inline

移除指定键值对

参数
key要删除的键值

该类的文档由以下文件生成: