[通用电气]通用库Map模板类

更新时间:2015-02-23    来源:英文短信    手机版     字体:

【www.bbyears.com--英文短信】

///通用库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 & aMap);
  ///默认析构函数
  ~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

本文来源:http://www.bbyears.com/zhufuduanxin/13156.html

猜你感兴趣

热门标签

更多>>

本类排行