, , , , , , . , , . , , -, , . , , , .
, . , . , , . . , , . Capacity - . , .
. , .
- , . , , . , .
:
if _List[i].Field3 = 'abcde' then
_List[i] - , , . :
var
tmp: tTestRecord2;
...
tmp := _List[i]; // copy of entire record
if tmp.Field3 = 'abcde' then
:
- . . , .
- , , .
TList<T> TArray<T>. .TList<T>.List , . , .
4 - , , .
if _List[i].Field3 = 'abcde' then
if _List.List[i].Field3 = 'abcde' then
.
:
{$APPTYPE CONSOLE}
uses
System.Diagnostics,
System.Generics.Collections;
type
tTestRecord2 = record
Field1: array[0..4999] of Integer;
Field2: array[0..4999] of Extended;
Field3: string;
end;
procedure Main;
const
N = 100000;
var
i: Integer;
Stopwatch: TStopwatch;
List: TList<tTestRecord2>;
Rec: tTestRecord2;
begin
List := TList<tTestRecord2>.Create;
List.Capacity := N;
for i := 0 to N-1 do
begin
List.Add(Rec);
end;
Stopwatch := TStopwatch.StartNew;
for i := 0 to N-1 do
begin
if List[i].Field3 = 'abcde' then
begin
Break;
end;
end;
Writeln(Stopwatch.ElapsedMilliseconds);
end;
begin
Main;
Readln;
end.
64 , . 700. List[i].Field3 List.List[i].Field3, . , , .
, . , .
, , Extended. 10, , . Double Real, Double.