1 (* Copyright (C) DooM 2D:Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE a_modes.inc}
17 // binary heap
20 interface
23 (*
24 * CmpObjT: class that contains class methods:
25 * class function less (const[ref] a, b: KeyT): Boolean;
26 *)
27 type
28 // WARNING! don't put structures into heap, use ponters or ids!
30 private
34 private
37 public
52 type
54 public
59 public
64 type
69 implementation
71 uses
72 SysUtils;
75 // ////////////////////////////////////////////////////////////////////////// //
76 class function TBinHeapKeyIntLess.less (const a, b: Integer): Boolean; inline; begin result := (a < b); end;
77 class function TBinHeapKeyIntGreat.less (const a, b: Integer): Boolean; inline; begin result := (a > b); end;
80 // ////////////////////////////////////////////////////////////////////////// //
82 begin
89 begin
96 begin
102 var
105 begin
107 begin
114 // swap
124 var
126 begin
127 //if (val = nil) then exit;
129 // grow?
131 begin
135 // increase counter
137 // insert element
139 begin
149 begin
155 begin
157 begin