加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Stack.inc_h 2.89 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.
*
*)
//------------------------------------------------------------------------------
// _TStack的声明
// Create by HouSisong, 2004.09.08
//------------------------------------------------------------------------------
{$ifndef __Stack_inc_h_}
{$define __Stack_inc_h_}
{$I DGLIntf.inc_h}
{$I Deque.inc_h}
_TDefaultStackBaseContainer = _TDeque; //默认使用_TDeque
//_TStack
//----------------------------------------------------------------------------
// 作用描述: 实现_IStack接口 ,内部使用_TDeque来实现
// 主要方法:参见_IStack接口的说明
//----------------------------------------------------------------------------
_TStack = class(TInterfacedObject,_IStack)
private
FBaseContainer : _TDefaultStackBaseContainer;
public
//实现_IStack接口
procedure Push(const Value: _ValueType); {$ifdef _DGL_Inline} inline; {$endif}
procedure Pop(); {$ifdef _DGL_Inline} inline; {$endif}
function GetTopValue():_ValueType; {$ifdef _DGL_Inline} inline; {$endif}
procedure SetTopValue(const aValue:_ValueType); {$ifdef _DGL_Inline} inline; {$endif}
property Top: _ValueType read GetTopValue write SetTopValue;
procedure Clear(); {$ifdef _DGL_Inline} inline; {$endif}
function Size(): _TNativeInt; {$ifdef _DGL_Inline} inline; {$endif}
function IsEmpty(): Boolean; {$ifdef _DGL_Inline} inline; {$endif}
function IsEquals(const AContainer: _IStack): Boolean; {$ifdef _DGL_Inline} inline; {$endif}
function Clone():_IStack; {$ifdef _DGL_Inline} inline; {$endif}
procedure Assign(const num:_TNativeInt;const Value: _ValueType);overload; {$ifdef _DGL_Inline} inline; {$endif}
procedure Assign(const ItBegin,ItEnd:_IIterator);overload; //todo: Warning inline on if _ValueType if "object" then error!!!
function GetSelfObj():TObject; {$ifdef _DGL_Inline} inline; {$endif}
public
constructor Create(); overload;
constructor Create(const num:_TNativeInt);overload;
constructor Create(const num:_TNativeInt;const Value:_ValueType);overload;
constructor Create(const ItBegin,ItEnd:_IIterator);overload;
constructor Create(const AStack:_TStack);overload;
destructor Destroy(); override;
end;
{$endif } // __Stack_inc_h_
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化