加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
DGLMap_Integer_TNotifyEvent.pas 2.51 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.
*
*)
//------------------------------------------------------------------------------
//DGLMap_Integer_TNotifyEvent
//例子
//具现化Integer<->TNotifyEvent的map容器和其迭代器
// Create by HouSisong, 2005.02.21
//------------------------------------------------------------------------------
unit DGLMap_Integer_TNotifyEvent;
interface
uses
SysUtils, Classes;
{$I DGLCfg.inc_h}
const
_NULL_Value = nil;
type
_KeyType = Integer;
_ValueType = TNotifyEvent;
{$define _DGL_NotHashFunction}
{$define _DGL_Compare} //比较函数
function _IsEqual(const a,b :_ValueType):boolean;{$ifdef _DGL_Inline} inline; {$endif} //result:=(a=b);
function _IsLess(const a,b :_ValueType):boolean;{$ifdef _DGL_Inline} inline; {$endif} //result:=(a<b); 默认排序准则
{$I Map.inc_h} //"类"模版的声明文件
{$I HashMap.inc_h} //"类"模版的声明文件
//out
type
IIntEventMapIterator = _IMapIterator;
IIntEventMap = _IMap;
IIntEventMultiMap = _IMultiMap;
TIntEventMap = _TMap;
TIntEventMultiMap = _TMultiMap;
TIntEventHashMap = _THashMap;
TIntEventHashMultiMap = _THashMultiMap;
implementation
uses
HashFunctions;
{$I Map.inc_pas} //"类"模版的实现文件
{$I HashMap.inc_pas} //"类"模版的实现文件
function _IsEqual(const a,b :_ValueType):boolean; //result:=(a=b);
begin
{$IFDEF CPU64BITS}
result:= ( (PInt64(@@a)^)=(PInt64(@@b)^) ) and ( (PInt64(UInt64(@@a)+8)^)=(PInt64(UInt64(@@b)+8)^) );
{$ELSE}
result:= (PInt64(@@a)^)=(PInt64(@@b)^);
{$ENDIF}
end;
function _IsLess(const a,b :_ValueType):boolean; //result:=(a<b); 默认排序准则
begin
{$IFDEF CPU64BITS}
if ((PInt64(@@a)^)<>(PInt64(@@b)^)) then
begin
result :=(PInt64(@@a)^)<(PInt64(@@b)^);
end
else
begin
result:= (PInt64(UInt64(@@a)+8)^)<(PInt64(UInt64(@@b)+8)^);
end;
{$ELSE}
result :=(PInt64(@@a)^)<(PInt64(@@b)^);
{$ENDIF}
end;
initialization
Assert(2*sizeof(_TNativeUInt)=sizeof(_ValueType));
end.
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化