Changeset 486 for trunk/AI/StdAI/Pile.pas
- Timestamp:
- Dec 8, 2023, 8:25:31 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AI/StdAI/Pile.pas
r447 r486 43 43 if (N <> 0) or (Size > CurrentSize) then 44 44 begin 45 FillChar(Ix, Size * sizeOf(Integer), 255);45 FillChar(Ix, Size * SizeOf(Integer), 255); 46 46 N := 0; 47 47 end; 48 48 CurrentSize := Size; 49 49 {$IFDEF DEBUG} 50 50 InUse := True; 51 51 {$ENDIF} … … 54 54 procedure Free; 55 55 begin 56 56 {$IFDEF DEBUG} 57 57 Assert(InUse); 58 58 InUse := False; … … 64 64 if N <> 0 then 65 65 begin 66 FillChar(Ix, CurrentSize * sizeOf(Integer), 255);66 FillChar(Ix, CurrentSize * SizeOf(Integer), 255); 67 67 N := 0; 68 68 end; 69 69 end; 70 70 71 // Parent(i) = (i-1)/2.72 function Put(Item, Value: Integer): Boolean; // O(lg(n))71 // Parent(i) = (i-1)/2. 72 function Put(Item, Value: Integer): Boolean; // O(lg(n)) 73 73 var 74 74 I, J: Integer; … … 92 92 while I > 0 do 93 93 begin 94 J := (I - 1) shr 1; // Parent(i) = (i-1)/294 J := (I - 1) shr 1; // Parent(i) = (i-1)/2 95 95 if Value >= bh[J].Value then 96 96 Break; … … 99 99 I := J; 100 100 end; 101 // 101 // Insert the new Item at the insertion point found. 102 102 bh[I].Value := Value; 103 103 bh[I].Item := Item;
Note:
See TracChangeset
for help on using the changeset viewer.