Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Collections/Pascal/collections-1.pas
Normal file
5
Task/Collections/Pascal/collections-1.pas
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var
|
||||
MyArray: array[1..5] of real;
|
||||
begin
|
||||
MyArray[1] := 4.35;
|
||||
end;
|
||||
6
Task/Collections/Pascal/collections-2.pas
Normal file
6
Task/Collections/Pascal/collections-2.pas
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
var
|
||||
MyArray: array of integer;
|
||||
begin
|
||||
setlength (MyArray, 10);
|
||||
MyArray[4] := 99;
|
||||
end;
|
||||
11
Task/Collections/Pascal/collections-3.pas
Normal file
11
Task/Collections/Pascal/collections-3.pas
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
var
|
||||
MyRecord: record
|
||||
x, y, z: real;
|
||||
presence: boolean;
|
||||
end;
|
||||
begin
|
||||
MyRecord.x := 0.3;
|
||||
MyRecord.y := 3.2;
|
||||
MyRecord.z := -4.0;
|
||||
MyRecord.presence := true;
|
||||
end;
|
||||
9
Task/Collections/Pascal/collections-4.pas
Normal file
9
Task/Collections/Pascal/collections-4.pas
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
type
|
||||
days = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
|
||||
var
|
||||
workDays, week, weekendDays: set of days;
|
||||
begin
|
||||
workdays := [Mon, Tue, Wed, Thu, Fri];
|
||||
week := workdays + [Sat, Sun];
|
||||
weekendDays := week - workdays;
|
||||
end;
|
||||
5
Task/Collections/Pascal/collections-5.pas
Normal file
5
Task/Collections/Pascal/collections-5.pas
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var
|
||||
MyString: String;
|
||||
begin
|
||||
MyString:= 'Some Text';
|
||||
end;
|
||||
19
Task/Collections/Pascal/collections-6.pas
Normal file
19
Task/Collections/Pascal/collections-6.pas
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
program ListDemo;
|
||||
uses
|
||||
classes;
|
||||
var
|
||||
MyList: TList;
|
||||
a, b, c: integer;
|
||||
i: integer;
|
||||
begin
|
||||
a := 1;
|
||||
b := 2;
|
||||
c := 3;
|
||||
MyList := TList.Create;
|
||||
MyList.Add(@a);
|
||||
MyList.Add(@c);
|
||||
MyList.Insert(1, @b);
|
||||
for i := MyList.IndexOf(MyList.First) to MyList.IndexOf(MyList.Last) do
|
||||
writeln (integer(MyList.Items[i]^));
|
||||
MyList.Destroy;
|
||||
end.
|
||||
34
Task/Collections/Pascal/collections-7.pas
Normal file
34
Task/Collections/Pascal/collections-7.pas
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
Program ex34;
|
||||
|
||||
{ Program to demonstrate the TCollection.AtInsert method }
|
||||
|
||||
Uses Objects, MyObject; { For TMyObject definition and registration }
|
||||
|
||||
Var C : PCollection;
|
||||
M : PMyObject;
|
||||
I : Longint;
|
||||
|
||||
Procedure PrintField (Dummy : Pointer; P : PMyObject);
|
||||
|
||||
begin
|
||||
Writeln ('Field : ',P^.GetField);
|
||||
end;
|
||||
|
||||
begin
|
||||
Randomize;
|
||||
C:=New(PCollection, Init(120, 10));
|
||||
Writeln ('Inserting 100 records at random places.');
|
||||
For I:=1 to 100 do
|
||||
begin
|
||||
M:=New(PMyObject, Init);
|
||||
M^.SetField(I-1);
|
||||
If I=1 then
|
||||
C^.Insert(M)
|
||||
else
|
||||
With C^ do
|
||||
AtInsert(Random(Count), M);
|
||||
end;
|
||||
Writeln ('Values : ');
|
||||
C^.Foreach(@PrintField);
|
||||
Dispose(C, Done);
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue