⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 priorityqueue.inc_h

📁 Delphi Generic Algorytms library - Maps, Lists, Hashmaps, Datastructures.
💻 INC_H
字号:
(*
 * DGL(The Delphi Generic Library)
 *
 * Copyright (c) 2004
 * HouSisong@263.net
 *
 * 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.
 *
 *)

//------------------------------------------------------------------------------
// _TPriorityQueue的声明
// Create by HouSisong, 2005.03.26
//------------------------------------------------------------------------------

{$ifndef  __PriorityQueue_inc_h_}
{$define  __PriorityQueue_inc_h_}


{$I DGLIntf.inc_h}
{$I Vector.inc_h}
{$I Algorithms.inc_h}

type
  _TDefaultPriorityQueueBaseContainer = _TVector; //默认使用_TVector

  //_TPriorityQueue
  //----------------------------------------------------------------------------
  // 作用描述: 实现_IQueue接口 ,内部使用_TDeque来实现
  // 主要方法:参见_IQueue接口的说明
  // 使用方式:
  // 注意事项:
  // 作    者: HouSisong , 2004.09.08
  // [相关资料]: (如果有的话)
  // [维护记录]: (类发布后,其修改需要记录下来:修改人、时间、主要原因内容)
  //----------------------------------------------------------------------------
  _TPriorityQueue = class(TInterfacedObject,_IPriorityQueue)
  private
    FBaseContainer   : _TDefaultPriorityQueueBaseContainer;
    FIsCompareFunctionUsedSelf :boolean;
    FOtherCompareFunction : TTestBinaryFunction;
    FCompareFunction : TTestBinaryFunctionOfObject;
    function OtherCompareFunction_To_CompareFunction(const Value0,Value1:_ValueType):Boolean; 
  public
    //实现_IQueue接口
    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(): Integer;                     {$ifdef _DGL_Inline} inline; {$endif}
    function  IsEmpty(): Boolean;                  {$ifdef _DGL_Inline} inline; {$endif}
    function  IsEquals(const AContainer: _IPriorityQueue): Boolean;    {$ifdef _DGL_Inline} inline; {$endif}
    function  Clone():_IPriorityQueue;                                   {$ifdef _DGL_Inline} inline; {$endif}
    procedure Assign(const num:integer;const Value: _ValueType);overload;     {$ifdef _DGL_Inline} inline; {$endif}
    procedure Assign(const ItBegin,ItEnd:_IIterator);overload;            
    function  GetSelfObj():TObject;     {$ifdef _DGL_Inline} inline; {$endif}
  public
    constructor Create(); overload;
    constructor Create(const AQueue:_TPriorityQueue);overload;
    constructor Create(const TestBinaryFunction:TTestBinaryFunction); overload;
    constructor Create(const TestBinaryFunction:TTestBinaryFunctionOfObject); overload;
    constructor Create(const ItBegin,ItEnd:_IIterator);overload;
    constructor Create(const ItBegin,ItEnd:_IIterator;const TestBinaryFunction:TTestBinaryFunction);overload;
    constructor Create(const ItBegin,ItEnd:_IIterator;const TestBinaryFunction:TTestBinaryFunctionOfObject);overload;   
    destructor  Destroy(); override;
  end;

{$endif }  // __PriorityQueue_inc_h_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -