pascalabcnet/TestSuite/CompilationSamples/LinkedList.pas

27 lines
605 B
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Использование LinkedList - двусвязного списка стандартной библиотеки - и его итератора
uses System.Collections,System.Collections.Generic;
procedure print(l: ICollection);
begin
foreach x: integer in l do
write(x,' ');
writeln;
end;
var l: LinkedList<integer> := new LinkedList<integer>;
begin
l.AddLast(3);
l.AddLast(5);
l.AddLast(7);
l.AddFirst(2);
print(l);
var a := new integer[10];
l.CopyTo(a,0);
print(a);
var lit: LinkedListNode<integer> := l.Find(5);
l.AddBefore(lit,777);
print(l);
end.