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, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE a_modes.inc}
16 // binary heap
19 interface
22 (*
23 * CmpObjT: class that contains class methods:
24 * class function less (const[ref] a, b: KeyT): Boolean;
25 *)
26 type
27 // WARNING! don't put structures into heap, use ponters or ids!
29 private
33 private
36 public
51 type
53 public
58 public
63 type
68 implementation
70 uses
71 SysUtils;
74 // ////////////////////////////////////////////////////////////////////////// //
75 class function TBinHeapKeyIntLess.less (const a, b: Integer): Boolean; inline; begin result := (a < b); end;
76 class function TBinHeapKeyIntGreat.less (const a, b: Integer): Boolean; inline; begin result := (a > b); end;
79 // ////////////////////////////////////////////////////////////////////////// //
81 begin
88 begin
95 begin
101 var
104 begin
106 begin
113 // swap
123 var
125 begin
126 //if (val = nil) then exit;
128 // grow?
130 begin
134 // increase counter
136 // insert element
138 begin
148 begin
154 begin
156 begin