加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Map.inc_h 5.82 KB
一键复制 编辑 原始数据 按行查看 历史
(*
* DGL(The Delphi Generic Library)
*
* Copyright (c) 2004
* HouSisong@gmail.com
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*)
//------------------------------------------------------------------------------
// _TMap\_TMultiMap的声明
// Create by HouSisong, 2006.10.20
//------------------------------------------------------------------------------
//Map.inc_h , Map.inc_pas
{$ifndef __Map_inc_h_}
{$define __Map_inc_h_}
{$I DGLIntf.inc_h}
{$I _RB_Tree.inc_h}
type
_TMapIterator = _TRBTreeBaseIterator;
type
_TMap_Base = class(TInterfacedObject)
protected
FRB_TRee : _TRB_Tree;
public
function GetItemValue(const Key: _KeyType): _ValueType; {$ifdef _DGL_Inline} inline; {$endif}
function ItBegin(): _IMapIterator; {$ifdef _DGL_Inline} inline; {$endif}
function ItEnd(): _IMapIterator; {$ifdef _DGL_Inline} inline; {$endif}
procedure Clear(); {$ifdef _DGL_Inline} inline; {$endif}
function Size(): _TNativeInt; {$ifdef _DGL_Inline} inline; {$endif}
function IsEmpty(): Boolean; {$ifdef _DGL_Inline} inline; {$endif}
function EraseValue(const Value:_ValueType):_TNativeInt; overload; {$ifdef _DGL_Inline} inline; {$endif}
function EraseValue(const Key:_KeyType;const Value:_ValueType):_TNativeInt; overload; {$ifdef _DGL_Inline} inline; {$endif}
function EraseKey(const Key:_KeyType):_TNativeInt; overload; {$ifdef _DGL_Inline} inline; {$endif}
procedure Erase(const ItPos:_IMapIterator); overload; //{$ifdef _DGL_Inline} inline; {$endif}
procedure Erase(const ItBegin,ItEnd: _IMapIterator); overload; //
function Count(const Key:_KeyType):_TNativeInt; {$ifdef _DGL_Inline} inline; {$endif}
function Find(const Key:_KeyType):_IMapIterator; {$ifdef _DGL_Inline} inline; {$endif}
function LowerBound(const Key:_KeyType):_IMapIterator; {$ifdef _DGL_Inline} inline; {$endif}
function UpperBound(const Key:_KeyType):_IMapIterator; {$ifdef _DGL_Inline} inline; {$endif}
procedure EqualRange(const Key:_KeyType;out ItBegin,ItEnd:_IMapIterator); {$ifdef _DGL_Inline} inline; {$endif}
function GetSelfObj():TObject; {$ifdef _DGL_Inline} inline; {$endif}
public
constructor Create();
destructor Destroy(); override;
end;
//----------------------------------------------------------------------------
// 作用描述: 底部利用_TRB_Tree实现的Map
// 主要方法:(参见_IMap的说明)
//----------------------------------------------------------------------------
_TMap = class(_TMap_Base,_IMap)
public
procedure SetItemValue(const Key: _KeyType;const Value: _ValueType); {$ifdef _DGL_Inline} inline; {$endif}
procedure Insert(const Key:_KeyType;const Value:_ValueType); overload; {$ifdef _DGL_Inline} inline; {$endif}
procedure Insert(const ItBegin,ItEnd:_IMapIterator);overload;
procedure Insert(const num:_TNativeInt;const Key:_KeyType;const Value:_ValueType); overload; {$ifdef _DGL_Inline} inline; {$endif}
procedure Assign(const ItBegin,ItEnd:_IMapIterator);overload;
procedure Assign(const num:_TNativeInt;const Key:_KeyType;const Value: _ValueType);overload; {$ifdef _DGL_Inline} inline; {$endif}
function Clone():_IMap; {$ifdef _DGL_Inline} inline; {$endif}
property Items[const Key:_KeyType]: _ValueType read GetItemValue write SetItemValue;
public
constructor Create(); overload;
constructor Create(const ItBegin,ItEnd:_IMapIterator);overload;
constructor Create(const AMap:_TMap);overload;
end;
//----------------------------------------------------------------------------
// 作用描述: 底部利用_TRB_Tree实现的MultiMap
// 主要方法:(参见_IMultiMap的说明)
//----------------------------------------------------------------------------
_TMultiMap = class(_TMap_Base,_IMultiMap,_IMap) //not _IMap
public
procedure SetItemValue(const Key: _KeyType;const Value: _ValueType); {$ifdef _DGL_Inline} inline; {$endif}
procedure Insert(const Key:_KeyType;const Value:_ValueType); overload; {$ifdef _DGL_Inline} inline; {$endif}
procedure Insert(const ItBegin,ItEnd:_IMapIterator);overload;
procedure Insert(const num:_TNativeInt;const Key:_KeyType;const Value:_ValueType); overload; {$ifdef _DGL_Inline} inline; {$endif}
procedure Assign(const ItBegin,ItEnd:_IMapIterator);overload;
procedure Assign(const num:_TNativeInt;const Key:_KeyType;const Value: _ValueType);overload; {$ifdef _DGL_Inline} inline; {$endif}
function Clone():_IMap; {$ifdef _DGL_Inline} inline; {$endif}
property Items[const Key:_KeyType]: _ValueType read GetItemValue write SetItemValue;
public
constructor Create(); overload;
constructor Create(const ItBegin,ItEnd:_IMapIterator);overload;
constructor Create(const AMultiMap:_TMultiMap);overload;
constructor Create(const num:_TNativeInt;const Key:_KeyType;const Value: _ValueType);overload;
end;
{$endif } // __Map_inc_h_
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化