最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
通用库Map模板类
时间:2008-04-26 编辑:简简单单 来源:一聚教程网
///通用库Map模板类
/**
* 通用库4.0版
* 这是一个映射类,提供基本的Map功能,这个映射是基于动态有序数组,查找方式用二分查找.
* 主要的方法有operator[],getValue(),getKey(),operator=,getLength(),RemoveByKey(),RemoveByIndex(),Clear(),Contains()等方法
* 除此之外,还提了一些类数组的方法.getCapaity(),getFirstIndex(),getLastIndex()等方法.
* 这个Map定义了内部Entry结构体:SEntry
* @author zdhsoft(祝冬华)
* @version 4.0
* @date 2008-04-01
* @file xmap.h
*/
#ifndef _X_MAP_H_
#define _X_MAP_H_
#include
namespace zdh
{
template
class XMap
{
///Map中的条目
struct SEntry
{
SEntry(const K & aKey)
:Key(aKey)
{}
SEntry(const K & aKey,const V & aValue)
:Key(aKey),Value(aValue)
{}
SEntry(const SEntry & aEntry)
:Key(aEntry.Key),Value(aEntry.Value)
{}
K Key;
V Value;
};
public:
///默认构造函数
XMap() {}
///默认拷贝构造函数
XMap(const XMap
///默认析构函数
~XMap() { Clear(); }
///清除所有元素
void Clear(bool bFree = false);
///确定map的容量
void ensureCapacity(XInt aMinimumCapacity) { m_Data.ensureCapacity(aMinimumCapacity); }
///取map元素的个数
XInt getLength() const { return m_Data.getLength(); }
//!取map的容量
XInt getCapacity() const { return m_Data.getCapacity(); }
///取map的最大容量
XInt getMaxCapacity() const { return 0x7FFFFFF0 / sizeof(SEntry); }
///取第一个下标
XInt getFirstIndex() const { return m_Data.getFirstIndex(); }
///取最后一个下标
XInt getLastIndex() const { return m_Data.getLastIndex(); }
///判断是否是第一个下标
bool isFirstInde
-
上一个: 通用库动态集合模板类
-
下一个: 两个栈共用一个顺序存储空间的代码
相关文章
- Java中Math类常用方法代码详解 07-29
- 阴阳师手游拉条类式神有哪些 07-19
- 烧脑小怪兽illi益智类手游AppStore限免中 07-17
- 查看import的类是出自哪个jar包的方法 07-01
- LED是什么意思 LED有哪些种类 06-30
- 艳阳下的运动精神 体育类手游推荐 06-15