/// Map template class of the general library
/**
* General Library version 4.0 <br>
* This is a ing class that provides basic Map functions. This ing is based on dynamic ordered arrays. Binary Search is used for searching. <br>
* Main methods include operator [], getValue (), getKey (), operator =, getLength (), RemoveByKey (), RemoveByIndex (), Clear (), Contains () and other methods <br>
* In addition, some methods such as getCapaity (), getFirstIndex (), and getLastIndex () are introduced.
* This Map defines the internal Entry struct: SEntry
* @ Author zdhsoft (Zhu Donghua)
* @ Version 4.0
* @ Date 2008-04-01
* @ File xmap. h
*/
# Ifndef _ X_MAP_H _
# Define _ X_MAP_H _
# Include <xarray. h>
Namespace zdh
{
Template <class K, class V>
Class XMap
{
/// Entries in 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:
/// Default constructor
XMap (){}
/// Default copy constructor
XMap (const XMap <K, V> & aMap );
/// Default destructor
~ XMap () {Clear ();}
/// Clear all elements
Void Clear (bool bFree = false );
/// Determine the map capacity
Void ensureCapacity (XInt aMinimumCapacity) {m_Data.ensureCapacity (aMinimumCapacity );}
/// Number of map elements
XInt getLength () const {return m_Data.getLength ();}
//! Map capacity
XInt getCapacity () const {return m_Data.getCapacity ();}
/// Maximum map capacity
XInt getMaxCapacity () const {return 0x7FFFFFF0/sizeof (SEntry );}
/// Obtain the first subscript
XInt getFirstIndex () const {return m_Data.getFirstIndex ();}
/// Obtain the last subscript
XInt getLastIndex () const {return m_Data.getLastIndex ();}
/// Determine whether it is the first subscript
Bool isFirstInde