Changeset 13 for trunk/UMemory.pas
- Timestamp:
- Sep 22, 2014, 5:25:11 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UMemory.pas
r9 r13 67 67 procedure SetSize(AValue: Integer); virtual; 68 68 public 69 procedure Invert; virtual; 69 70 function GetInteger: Integer; virtual; 70 71 procedure SetInteger(Value: Integer); virtual; … … 83 84 FData: PByte; 84 85 FSize: Integer; 85 function GetInteger: Integer; override;86 procedure SetInteger(Value: Integer); override;87 86 function GetSize: Integer; override; 88 87 procedure SetSize(AValue: Integer); override; … … 90 89 procedure SetItem(Index: Integer; AValue: Byte); override; 91 90 public 91 function GetInteger: Integer; override; 92 procedure SetInteger(Value: Integer); override; 93 procedure Clear(Value: Byte = 0); override; 94 procedure ReadBlock(Block: TBitBlock; Position: Integer); override; 95 procedure WriteBlock(Block: TBitBlock; Position: Integer); override; 96 property Data: PByte read FData; 97 procedure Invert; override; 92 98 end; 93 99 … … 96 102 97 103 { TBitMemory } 104 105 procedure TBitMemory.Clear(Value: Byte); 106 begin 107 if (Size and 7) = 0 then begin 108 if Value = 0 then FillChar(FData^, Size shr 3, 0) 109 else FillChar(FData^, Size shr 3, $ff); 110 end else inherited; 111 end; 112 113 procedure TBitMemory.ReadBlock(Block: TBitBlock; Position: Integer); 114 begin 115 if Block is TBitMemory then begin 116 if (Position and 7) = 0 then begin 117 if (Block.Size and 7) = 0 then 118 Move(PByte(FData + Position shr 3)^, TBitMemory(Block).Data^, Block.Size shr 3) 119 else inherited; 120 end else inherited; 121 end else inherited; 122 end; 123 124 procedure TBitMemory.WriteBlock(Block: TBitBlock; Position: Integer); 125 begin 126 if Block is TBitMemory then begin 127 if (Position and 7) = 0 then begin 128 if (Block.Size and 7) = 0 then 129 Move(TBitMemory(Block).Data^, PByte(FData + Position shr 3)^, Block.Size shr 3) 130 else inherited; 131 end else inherited; 132 end else inherited; 133 end; 134 135 procedure TBitMemory.Invert; 136 var 137 I: Integer; 138 begin 139 if (Size and 7) = 0 then begin 140 for I := 0 to (Size shr 3) - 1 do 141 PByte(FData + I)^ := PByte(FData + I)^ xor $ff; 142 end 143 else inherited; 144 145 end; 98 146 99 147 function TBitMemory.GetInteger: Integer; … … 176 224 end; 177 225 226 procedure TBitBlock.Invert; 227 var 228 I: Integer; 229 begin 230 for I := 0 to Size - 1 do 231 Items[I] := not Items[I]; 232 end; 233 178 234 function TBitBlock.GetInteger: Integer; 179 235 begin
Note:
See TracChangeset
for help on using the changeset viewer.