Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project1;
- {$APPTYPE CONSOLE}
- uses
- SysUtils,
- Classes,
- Windows,
- Generics.Collections,
- Generics.Defaults;
- var
- Dict : TDictionary<String, Boolean>;
- List : TStringList;
- TC : Cardinal;
- i : integer;
- b : Boolean;
- begin
- List := TStringList.Create;
- Dict := TDictionary<String, Boolean>.Create();
- TC := GetTickCount();
- List.LoadFromFile('test.txt');
- Writeln(Format('Reading file speed: %d ms.', [GetTickCount() - TC]));
- TC := GetTickCount();
- for i := 0 to List.Count - 1 do
- begin
- Dict.Add(List[i], True);
- end;
- Writeln(Format('Adding to the dictionary: %d ms.', [GetTickCount() - TC]));
- TC := GetTickCount();
- for i := 0 to List.Count - 1 do
- begin
- b := Dict[List[i]];
- if not b
- then Break;
- end;
- Writeln(Format('Dictionary reading: %d ms.', [GetTickCount() - TC]));
- List.Free;
- Dict.Free;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement